NFC: pn533: double free on error in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 17 May 2016 07:32:19 +0000 (10:32 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 4 Jul 2016 10:15:00 +0000 (12:15 +0200)
We can't pass devm_ allocated pointers to kfree() because they will be
freed again after the drive is unloaded.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn533/usb.c

index 8ca060324b6aa9ef9a200e5b26b249f3e7e4003d..33ed78be2750455c34fd51d3b69611f177b52374 100644 (file)
@@ -464,10 +464,8 @@ static int pn533_usb_probe(struct usb_interface *interface,
                return -ENOMEM;
 
        in_buf = kzalloc(in_buf_len, GFP_KERNEL);
-       if (!in_buf) {
-               rc = -ENOMEM;
-               goto out_free_phy;
-       }
+       if (!in_buf)
+               return -ENOMEM;
 
        phy->udev = usb_get_dev(interface_to_usbdev(interface));
        phy->interface = interface;
@@ -554,8 +552,7 @@ error:
        usb_free_urb(phy->out_urb);
        usb_put_dev(phy->udev);
        kfree(in_buf);
-out_free_phy:
-       kfree(phy);
+
        return rc;
 }