From: James Bottomley Date: Fri, 12 Mar 2010 22:14:42 +0000 (-0600) Subject: [SCSI] enclosure: fix error path - actually return ERR_PTR() on error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a91c1be21704113b023919826c6d531da46656ef;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [SCSI] enclosure: fix error path - actually return ERR_PTR() on error we also need to clean up and free the cdev. Reported-by: Jani Nikula Cc: Stable Tree Signed-off-by: James Bottomley --- diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 48c84a58163e..00e5fcac8fdf 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -285,8 +285,11 @@ enclosure_component_register(struct enclosure_device *edev, cdev->groups = enclosure_groups; err = device_register(cdev); - if (err) - ERR_PTR(err); + if (err) { + ecomp->number = -1; + put_device(cdev); + return ERR_PTR(err); + } return ecomp; }