Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: whci-hcd: fix NULL dereference on allocation failure

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>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
3821bf4a 644034c2

+4 -4
+4 -4
drivers/usb/host/whci/hcd.c
··· 238 238 239 239 static int whc_probe(struct umc_dev *umc) 240 240 { 241 - int ret = -ENOMEM; 241 + int ret; 242 242 struct usb_hcd *usb_hcd; 243 - struct wusbhc *wusbhc = NULL; 244 - struct whc *whc = NULL; 243 + struct wusbhc *wusbhc; 244 + struct whc *whc; 245 245 struct device *dev = &umc->dev; 246 246 247 247 usb_hcd = usb_create_hcd(&whc_hc_driver, dev, "whci"); 248 248 if (usb_hcd == NULL) { 249 249 dev_err(dev, "unable to create hcd\n"); 250 - goto error; 250 + return -ENOMEM; 251 251 } 252 252 253 253 usb_hcd->wireless = 1;