WSL2-Linux-Kernel/drivers/gpu
Yuan Can bc79cb9fb0 drm/vc4: Fix missing platform_unregister_drivers() call in vc4_drm_register()
[ Upstream commit cf53db768a ]

A problem about modprobe vc4 failed is triggered with the following log
given:

 [  420.327987] Error: Driver 'vc4_hvs' is already registered, aborting...
 [  420.333904] failed to register platform driver vc4_hvs_driver [vc4]: -16
 modprobe: ERROR: could not insert 'vc4': Device or resource busy

The reason is that vc4_drm_register() returns platform_driver_register()
directly without checking its return value, if platform_driver_register()
fails, it returns without unregistering all the vc4 drivers, resulting the
vc4 can never be installed later.
A simple call graph is shown as below:

 vc4_drm_register()
   platform_register_drivers() # all vc4 drivers are registered
   platform_driver_register()
     driver_register()
       bus_add_driver()
         priv = kzalloc(...) # OOM happened
   # return without unregister drivers

Fixing this problem by checking the return value of
platform_driver_register() and do platform_unregister_drivers() if
error happened.

Fixes: c8b75bca92 ("drm/vc4: Add KMS support for Raspberry Pi.")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20221103014705.109322-1-yuancan@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 09:58:18 +01:00
..
drm drm/vc4: Fix missing platform_unregister_drivers() call in vc4_drm_register() 2022-11-16 09:58:18 +01:00
host1x gpu: host1x: Fix a memory leak in 'host1x_remove()' 2022-04-08 14:23:36 +02:00
ipu-v3 gpu: ipu-v3: Fix dev_dbg frequency output 2022-04-20 09:34:16 +02:00
trace
vga
Makefile