drivers: core: prevent dereferencing of a null pointer in device_move()
PATCH 1/1 drivers: core: prevent dereferencing of a null pointer in device_move()
Parameter new_parent can be equal to NULL. In this case if the drm_order parameter is equal to DRM_ORDER_DEV_AFTER_PARENT or DRM_ORDER_PARENT_BEFORE_DEV, a null pointer will be dereferenced.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Signed-off-by Roman Smirnov <[email protected]>
Reviewed-by Sergey Shtylyov <[email protected]>
--- drivers/base/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/base/core.c +8 -0
@@ -4593,10 +4593,18 @@ int device_move(struct device *dev, struct device *new_parent,case DPM_ORDER_NONE :break ;case DPM_ORDER_DEV_AFTER_PARENT : +if (!new_parent) { + error = -EINVAL ; + goto out; + }device_pm_move_after (dev, new_parent);devices_kset_move_after (dev, new_parent);break ;case DPM_ORDER_PARENT_BEFORE_DEV : +if (!new_parent) { + error = -EINVAL ; + goto out; + }device_pm_move_before (new_parent, dev);devices_kset_move_before (new_parent, dev);break ;
Signature · 1 line
2.34.1