[kuba:dev_addr 20/23] drivers/base/property.c:1016:16: warning: function may return address of local variable

From: kernel test robot
Date: Thu Oct 07 2021 - 04:02:12 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git dev_addr
head: 973ae9d60a15efacbd36aa6095c34871f3147ca0
commit: c419c9d578ca5ac351185b8cc448d12236aebf55 [20/23] device property: add a helper for loading netdev->dev_addr
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git/commit/?id=c419c9d578ca5ac351185b8cc448d12236aebf55
git remote add kuba https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git
git fetch --no-tags kuba dev_addr
git checkout c419c9d578ca5ac351185b8cc448d12236aebf55
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/base/property.c: In function 'device_get_ethdev_addr':
>> drivers/base/property.c:1016:16: warning: function may return address of local variable [-Wreturn-local-addr]
1016 | return ret;
| ^~~
drivers/base/property.c:1010:12: note: declared here
1010 | u8 addr[ETH_ALEN];
| ^~~~


vim +1016 drivers/base/property.c

999
1000 /**
1001 * device_get_ethdev_addr - Set netdev's MAC address from a given device
1002 * @dev: Pointer to the device
1003 * @netdev: Pointer to netdev to write the address to
1004 *
1005 * Wrapper around device_get_mac_address() which writes the address
1006 * directly to netdev->dev_addr.
1007 */
1008 void *device_get_ethdev_addr(struct device *dev, struct net_device *netdev)
1009 {
1010 u8 addr[ETH_ALEN];
1011 void *ret;
1012
1013 ret = device_get_mac_address(dev, addr, ETH_ALEN);
1014 if (ret)
1015 eth_hw_addr_set(netdev, addr);
> 1016 return ret;
1017 }
1018 EXPORT_SYMBOL(device_get_ethdev_addr);
1019

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip