NFC: pn533: Fix use after free
authorSzymon Janc <szymon.janc@tieto.com>
Mon, 29 Oct 2012 13:04:43 +0000 (14:04 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 19 Nov 2012 23:09:26 +0000 (00:09 +0100)
cmd was freed in pn533_dep_link_up regardless of
pn533_send_cmd_frame_async return code. Cmd is passed as argument to
pn533_in_dep_link_up_complete callback and should be freed there.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn533.c

index 328f2b66491e68f0ea571dc0bd3babcf1699c2d0..84a2e77ab5debbfdc77747ccdee22907f755bbec 100644 (file)
@@ -1820,12 +1820,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
        rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame,
                                dev->in_maxlen, pn533_in_dep_link_up_complete,
                                cmd, GFP_KERNEL);
-       if (rc)
-               goto out;
-
-
-out:
-       kfree(cmd);
+       if (rc < 0)
+               kfree(cmd);
 
        return rc;
 }