From: Phil Carmody Date: Mon, 14 Dec 2009 18:28:12 +0000 (+0200) Subject: driver core: Prevent reference to freed memory on error path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=99b28f1b4126582f87ce454d4affb823bddf2cd8;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git driver core: Prevent reference to freed memory on error path priv is drv->p. So only free drv->p after we've finished using priv. Found using a static code analysis tool Signed-off-by: Phil Carmody Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 63c143e54a5..c0c5a43d9fb 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -703,9 +703,9 @@ int bus_add_driver(struct device_driver *drv) return 0; out_unregister: + kobject_put(&priv->kobj); kfree(drv->p); drv->p = NULL; - kobject_put(&priv->kobj); out_put_bus: bus_put(bus); return error;