From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
To: linux-nfc@lists.01.org
Cc: linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org,
Samuel Ortiz <sameo@linux.intel.com>,
Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Subject: [PATCH] pn533: fix stack being used as URB transfer_buffer
Date: Tue, 06 Aug 2013 14:09:24 +0300 [thread overview]
Message-ID: <20130806110924.26024.75370.stgit@localhost6.localdomain6> (raw)
Patch fixes incorrect stack usage in pn533_send_ack(). Function currently sets
stack as transfer_buffer (stack may not be dma-able, must not be used for URB
buffers) and returns (stack buffer is still in use after function call).
Patch is only compile tested.
Cc: stable@vger.kernel.org
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
---
drivers/nfc/pn533.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index daf92ac..2da0775 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -382,6 +382,8 @@ struct pn533 {
u8 tgt_active_prot;
u8 tgt_mode;
+ void *ack_buf;
+
struct pn533_frame_ops *ops;
};
@@ -761,7 +763,13 @@ static int pn533_send_ack(struct pn533 *dev, gfp_t flags)
nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
- dev->out_urb->transfer_buffer = ack;
+ if (!dev->ack_buf) {
+ dev->ack_buf = kmemdup(ack, sizeof(ack), flags);
+ if (!dev->ack_buf)
+ return -ENOMEM;
+ }
+
+ dev->out_urb->transfer_buffer = dev->ack_buf;
dev->out_urb->transfer_buffer_length = sizeof(ack);
rc = usb_submit_urb(dev->out_urb, flags);
@@ -2824,6 +2832,7 @@ error:
usb_free_urb(dev->in_urb);
usb_free_urb(dev->out_urb);
usb_put_dev(dev->udev);
+ kfree(dev->ack_buf);
kfree(dev);
return rc;
}
@@ -2855,6 +2864,7 @@ static void pn533_disconnect(struct usb_interface *interface)
usb_free_urb(dev->in_urb);
usb_free_urb(dev->out_urb);
+ kfree(dev->ack_buf);
kfree(dev);
nfc_dev_info(&interface->dev, "NXP PN533 NFC device disconnected");
reply other threads:[~2013-08-06 11:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130806110924.26024.75370.stgit@localhost6.localdomain6 \
--to=jussi.kivilinna@iki.fi \
--cc=aloisio.almeida@openbossa.org \
--cc=lauro.venancio@openbossa.org \
--cc=linux-nfc@lists.01.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox