rtl8187: fix use after free on failure path in rtl8187_probe()
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 28 Mar 2014 20:26:15 +0000 (00:26 +0400)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 31 Mar 2014 17:47:41 +0000 (13:47 -0400)
If allocation of io_dmabuf fails, rtl8187_probe() calls usb_put_dev(udev)
while usb_get_dev(udev) is not called yet. As a result refcnt is decremented
incorrectly and usb_dev can be used after memory deallocation.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rtl818x/rtl8187/dev.c

index 2c79bcc6ae65e96e3e604f4c5ffbb4d52daea310..0ca17cda48fa1c01b3a8dd2ed98c5fe0c5646640 100644 (file)
@@ -1636,10 +1636,10 @@ static int rtl8187_probe(struct usb_interface *intf,
 
  err_free_dmabuf:
        kfree(priv->io_dmabuf);
- err_free_dev:
-       ieee80211_free_hw(dev);
        usb_set_intfdata(intf, NULL);
        usb_put_dev(udev);
+ err_free_dev:
+       ieee80211_free_hw(dev);
        return err;
 }