All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: stefan@osg.samsung.com
Cc: linux-wpan@vger.kernel.org
Subject: [bug report] ieee802154: atusb: try to read permanent extended address from device
Date: Mon, 12 Dec 2016 15:28:19 +0300	[thread overview]
Message-ID: <20161212122819.GA10577@elgon.mountain> (raw)

Hello Stefan Schmidt,

The patch 6cc33eba232c: "ieee802154: atusb: try to read permanent
extended address from device" from Dec 5, 2016, leads to the
following static checker warning:

	drivers/net/ieee802154/atusb.c:714 atusb_set_extended_addr()
	error: doing dma on the stack (buffer)

drivers/net/ieee802154/atusb.c
   698  static int atusb_set_extended_addr(struct atusb *atusb)
   699  {
   700          struct usb_device *usb_dev = atusb->usb_dev;
   701          unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN];
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   702          __le64 extended_addr;
   703          u64 addr;
   704          int ret;
   705  
   706          /* Firmware versions before 0.3 do not support the EUI64_READ command.
   707           * Just use a random address and be done */
   708          if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
   709                  ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
   710                  return 0;
   711          }
   712  
   713          /* Firmware is new enough so we fetch the address from EEPROM */
   714          ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
   715                                  ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
   716                                  buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
                                        ^^^^^^

Stack memory is not dma-able and this is especially important for 4.9
and later kernels because of the virtually mapped stacks I believe?

   717          if (ret < 0)
   718                  dev_err(&usb_dev->dev, "failed to fetch extended address\n");
   719  
   720          memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN);
   721          /* Check if read address is not empty and the unicast bit is set correctly */
   722          if (!ieee802154_is_valid_extended_unicast_addr(extended_addr)) {
   723                  dev_info(&usb_dev->dev, "no permanent extended address found, random address set\n");
   724                  ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
   725          } else {
   726                  atusb->hw->phy->perm_extended_addr = extended_addr;
   727                  addr = swab64((__force u64)atusb->hw->phy->perm_extended_addr);
   728                  dev_info(&usb_dev->dev, "Read permanent extended address %8phC from device\n",
   729                          &addr);
   730          }
   731  
   732          return ret;
   733  }

See these older warnings as well:

drivers/net/ieee802154/atusb.c:123 atusb_read_reg() error: doing dma on the stack (&value)
drivers/net/ieee802154/atusb.c:126 atusb_read_reg() error: uninitialized symbol 'value'.
drivers/net/ieee802154/atusb.c:615 atusb_get_and_show_revision() error: doing dma on the stack (buffer)
drivers/net/ieee802154/atusb.c:643 atusb_get_and_show_build() error: doing dma on the stack (build)

regards,
dan carpenter

             reply	other threads:[~2016-12-12 12:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-12 12:28 Dan Carpenter [this message]
2016-12-15  9:35 ` [bug report] ieee802154: atusb: try to read permanent extended address from device Stefan Schmidt
2016-12-15 17:43 ` Stefan Schmidt

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=20161212122819.GA10577@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=linux-wpan@vger.kernel.org \
    --cc=stefan@osg.samsung.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 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.