From: Szymon Janc Date: Mon, 29 Oct 2012 13:04:43 +0000 (+0100) Subject: NFC: pn533: Fix use after free X-Git-Tag: upstream/snapshot3+hdmi~6176^2~2^2~2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=770f750bc2b8312489c8e45306f551d08a319d3c;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git NFC: pn533: Fix use after free 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 Signed-off-by: Samuel Ortiz --- diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 328f2b6..84a2e77 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -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; }