[PATCH 28/46] Driver core: Fix cleanup in device_create_vargs().

From: Greg Kroah-Hartman
Date: Thu Oct 16 2008 - 13:25:46 EST

From: Cornelia Huck <cornelia.huck@xxxxxxxxxx>

If device_register() in device_create_vargs() fails, the device
must be cleaned up with put_device() (which is also fine on NULL)
instead of kfree().

Signed-off-by: Cornelia Huck <cornelia.huck@xxxxxxxxxx>
Cc: stable <stable@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
drivers/base/core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index aac91e8..9649d1c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1256,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
return dev;

- kfree(dev);
+ put_device(dev);
return ERR_PTR(retval);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/