Skip to content

Commit

Permalink
[SCSI] enclosure: fix error path - actually return ERR_PTR() on error
Browse files Browse the repository at this point in the history
we also need to clean up and free the cdev.

Reported-by: Jani Nikula <ext-jani.1.nikula@nokia.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
James Bottomley authored and James Bottomley committed Jul 27, 2010
1 parent aac3118 commit a91c1be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/misc/enclosure.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a91c1be

Please sign in to comment.