Skip to content

Commit

Permalink
NFC: pn533: double free on error in probe()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
Dan Carpenter authored and Samuel Ortiz committed Jul 4, 2016
1 parent f86dec9 commit 6d2f70c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/nfc/pn533/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -554,8 +552,7 @@ static int pn533_usb_probe(struct usb_interface *interface,
usb_free_urb(phy->out_urb);
usb_put_dev(phy->udev);
kfree(in_buf);
out_free_phy:
kfree(phy);

return rc;
}

Expand Down

0 comments on commit 6d2f70c

Please sign in to comment.