Skip to content

Commit

Permalink
Driver core: Fix cleanup in device_create_vargs().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Cornelia Huck authored and Greg Kroah-Hartman committed Oct 16, 2008
1 parent 5739411 commit 286661b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 286661b

Please sign in to comment.