All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Schmidt <stefan@osg.samsung.com>
To: marcel@holtmann.org
Cc: linux-wpan@vger.kernel.org, Alexander Aring <aar@pengutronix.de>,
	Stefan Schmidt <stefan@osg.samsung.com>
Subject: [PATCH bluetooth 3/5] ieee802154: atusb: do not use the stack for address fetching to make it DMA able
Date: Sat,  7 Jan 2017 01:18:55 +0100	[thread overview]
Message-ID: <1483748337-4862-4-git-send-email-stefan@osg.samsung.com> (raw)
In-Reply-To: <1483748337-4862-1-git-send-email-stefan@osg.samsung.com>

 From 4.9 we should really avoid using the stack here as this will not be DMA
able on various platforms. This changes a buffer that was introduced in the
4.10 merge window.

Fixes: 6cc33eba232c ("ieee802154: atusb: try to read permanent extended
address from device")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
---
 drivers/net/ieee802154/atusb.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 67790f8..63cb679 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -721,7 +721,7 @@ static int atusb_get_and_show_chip(struct atusb *atusb)
 static int atusb_set_extended_addr(struct atusb *atusb)
 {
 	struct usb_device *usb_dev = atusb->usb_dev;
-	unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN];
+	unsigned char *buffer;
 	__le64 extended_addr;
 	u64 addr;
 	int ret;
@@ -733,6 +733,10 @@ static int atusb_set_extended_addr(struct atusb *atusb)
 		return 0;
 	}
 
+	buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
+	if (!buffer)
+		return -ENOMEM;
+
 	/* Firmware is new enough so we fetch the address from EEPROM */
 	ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
 				ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
@@ -740,6 +744,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
 	if (ret < 0) {
 		dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
 		ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
+		kfree(buffer);
 		return ret;
 	}
 
@@ -755,6 +760,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
 			&addr);
 	}
 
+	kfree(buffer);
 	return ret;
 }
 
-- 
2.5.5


  parent reply	other threads:[~2017-01-07  0:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-07  0:18 [pull-request bluetooth] wpan fixes for 4.10 2017-01-07 Stefan Schmidt
2017-01-07  0:18 ` [PATCH bluetooth 1/5] ieee802154: atusb: do not use the stack for buffers to make them DMA able Stefan Schmidt
2017-01-07  0:18   ` Stefan Schmidt
2017-01-07  8:52   ` Greg KH
2017-01-07  0:18 ` [PATCH bluetooth 2/5] ieee802154: atusb: make sure we set a randaom extended address if fetching fails Stefan Schmidt
2017-01-07  0:18 ` Stefan Schmidt [this message]
2017-01-07  0:18 ` [PATCH bluetooth 4/5] at86rf230: Allow slow GPIO pins for "rstn" Stefan Schmidt
2017-01-07  0:18 ` [PATCH bluetooth 5/5] ieee802154: atusb: fix driver to work with older firmware versions Stefan Schmidt
2017-01-12  7:56 ` [pull-request bluetooth] wpan fixes for 4.10 2017-01-07 Stefan Schmidt
2017-01-12 21:39 ` Marcel Holtmann

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=1483748337-4862-4-git-send-email-stefan@osg.samsung.com \
    --to=stefan@osg.samsung.com \
    --cc=aar@pengutronix.de \
    --cc=linux-wpan@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.