Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
* [bug report] ieee802154: atusb: try to read permanent extended address from device
@ 2016-12-12 12:28 Dan Carpenter
  2016-12-15  9:35 ` Stefan Schmidt
  2016-12-15 17:43 ` Stefan Schmidt
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-12-12 12:28 UTC (permalink / raw)
  To: stefan; +Cc: linux-wpan

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-15 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12 12:28 [bug report] ieee802154: atusb: try to read permanent extended address from device Dan Carpenter
2016-12-15  9:35 ` Stefan Schmidt
2016-12-15 17:43 ` Stefan Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox