Driver core: Fix cleanup in device_create_vargs().
authorCornelia Huck <cornelia.huck@de.ibm.com>
Wed, 3 Sep 2008 16:26:41 +0000 (18:26 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 16 Oct 2008 16:24:49 +0000 (09:24 -0700)
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@de.ibm.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c

index aac91e89d6afcecdb1ce9c23292095876c568c6b..9649d1c422a4bd1abbc71ef7849d7b02193fc52a 100644 (file)
@@ -1256,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
        return dev;
 
 error:
-       kfree(dev);
+       put_device(dev);
        return ERR_PTR(retval);
 }
 EXPORT_SYMBOL_GPL(device_create_vargs);