Skip to content

Commit

Permalink
USB: whci-hcd: fix NULL dereference on allocation failure
Browse files Browse the repository at this point in the history
If usb_create_hcd() fails here then we dereference "whc" inside the call
to whc_clean_up() before it has been set.  The compiler would have
warned about this if we hadn't initialized all the pointers to NULL at
the start of the function.  I've cleaned that up as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Aug 15, 2012
1 parent 644034c commit 3821bf4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/usb/host/whci/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@ static struct hc_driver whc_hc_driver = {

static int whc_probe(struct umc_dev *umc)
{
int ret = -ENOMEM;
int ret;
struct usb_hcd *usb_hcd;
struct wusbhc *wusbhc = NULL;
struct whc *whc = NULL;
struct wusbhc *wusbhc;
struct whc *whc;
struct device *dev = &umc->dev;

usb_hcd = usb_create_hcd(&whc_hc_driver, dev, "whci");
if (usb_hcd == NULL) {
dev_err(dev, "unable to create hcd\n");
goto error;
return -ENOMEM;
}

usb_hcd->wireless = 1;
Expand Down

0 comments on commit 3821bf4

Please sign in to comment.