aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-05-10 05:35:17 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-10 18:14:29 -0400
commit2d2924af96881f3300239156d6ff316a1a3e48e5 (patch)
tree1df8f756cf9047063d467ae56dd88080c5dd01eb
parent1be91314532c4a2779fa17665b6d0368972b570b (diff)
net: ethernet: fix similar warning reported by kbuild test robot
This patch fixes following (similar) warning reported by kbuild test robot: In function ‘memcpy’, inlined from ‘smsc75xx_init_mac_address’ at drivers/net/usb/smsc75xx.c:778:3, inlined from ‘smsc75xx_bind’ at drivers/net/usb/smsc75xx.c:1501:2: ./include/linux/string.h:355:9: warning: argument 2 null where non-null expected [-Wnonnull] return __builtin_memcpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/usb/smsc75xx.c: In function ‘smsc75xx_bind’: ./include/linux/string.h:355:9: note: in a call to built-in function ‘__builtin_memcpy’ I've replaced the offending memcpy with ether_addr_copy, because I'm 100% sure, that of_get_mac_address can't return NULL as it returns valid pointer or ERR_PTR encoded value, nothing else. I'm hesitant to just change IS_ERR into IS_ERR_OR_NULL check, as this would make the warning disappear also, but it would be confusing to check for impossible return value just to make a compiler happy. I'm now changing all occurencies of memcpy to ether_addr_copy after the of_get_mac_address call, as it's very likely, that we're going to get similar reports from kbuild test robot in the future. Fixes: a51645f70f63 ("net: ethernet: support of_get_mac_address new ERR_PTR error") Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Petr Štetiar <ynezz@true.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c2
-rw-r--r--drivers/net/ethernet/arc/emac_main.c2
-rw-r--r--drivers/net/ethernet/cavium/octeon/octeon_mgmt.c2
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c2
-rw-r--r--drivers/net/ethernet/freescale/fec_mpc52xx.c2
-rw-r--r--drivers/net/ethernet/freescale/fman/mac.c2
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c2
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c2
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c2
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c2
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c2
-rw-r--r--drivers/net/ethernet/marvell/sky2.c2
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c2
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c2
-rw-r--r--drivers/net/ethernet/nxp/lpc_eth.c2
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c2
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c2
19 files changed, 19 insertions, 19 deletions
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 37ebd890ef51..9e06dff619c3 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -871,7 +871,7 @@ static int emac_probe(struct platform_device *pdev)
871 /* Read MAC-address from DT */ 871 /* Read MAC-address from DT */
872 mac_addr = of_get_mac_address(np); 872 mac_addr = of_get_mac_address(np);
873 if (!IS_ERR(mac_addr)) 873 if (!IS_ERR(mac_addr))
874 memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); 874 ether_addr_copy(ndev->dev_addr, mac_addr);
875 875
876 /* Check if the MAC address is valid, if not get a random one */ 876 /* Check if the MAC address is valid, if not get a random one */
877 if (!is_valid_ether_addr(ndev->dev_addr)) { 877 if (!is_valid_ether_addr(ndev->dev_addr)) {
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 7f89ad5c336d..13a1d99b29c6 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -961,7 +961,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
961 mac_addr = of_get_mac_address(dev->of_node); 961 mac_addr = of_get_mac_address(dev->of_node);
962 962
963 if (!IS_ERR(mac_addr)) 963 if (!IS_ERR(mac_addr))
964 memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); 964 ether_addr_copy(ndev->dev_addr, mac_addr);
965 else 965 else
966 eth_hw_addr_random(ndev); 966 eth_hw_addr_random(ndev);
967 967
diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index 15b1130aa4ae..0e5de88fd6e8 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -1504,7 +1504,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
1504 mac = of_get_mac_address(pdev->dev.of_node); 1504 mac = of_get_mac_address(pdev->dev.of_node);
1505 1505
1506 if (!IS_ERR(mac)) 1506 if (!IS_ERR(mac))
1507 memcpy(netdev->dev_addr, mac, ETH_ALEN); 1507 ether_addr_copy(netdev->dev_addr, mac);
1508 else 1508 else
1509 eth_hw_addr_random(netdev); 1509 eth_hw_addr_random(netdev);
1510 1510
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 953ee5616801..5e1aff9a5fd6 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -1413,7 +1413,7 @@ static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev)
1413 1413
1414 mac_addr = of_get_mac_address(np); 1414 mac_addr = of_get_mac_address(np);
1415 if (!IS_ERR(mac_addr)) 1415 if (!IS_ERR(mac_addr))
1416 memcpy(pdata->dev_addr, mac_addr, sizeof(pdata->dev_addr)); 1416 ether_addr_copy(pdata->dev_addr, mac_addr);
1417 1417
1418 return pdata; 1418 return pdata;
1419} 1419}
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 7b7e526869a7..30cdb246d020 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -903,7 +903,7 @@ static int mpc52xx_fec_probe(struct platform_device *op)
903 */ 903 */
904 mac_addr = of_get_mac_address(np); 904 mac_addr = of_get_mac_address(np);
905 if (!IS_ERR(mac_addr)) { 905 if (!IS_ERR(mac_addr)) {
906 memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); 906 ether_addr_copy(ndev->dev_addr, mac_addr);
907 } else { 907 } else {
908 struct mpc52xx_fec __iomem *fec = priv->fec; 908 struct mpc52xx_fec __iomem *fec = priv->fec;
909 909
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 9cd2c28d17df..7ab8095db192 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -729,7 +729,7 @@ static int mac_probe(struct platform_device *_of_dev)
729 err = -EINVAL; 729 err = -EINVAL;
730 goto _return_of_get_parent; 730 goto _return_of_get_parent;
731 } 731 }
732 memcpy(mac_dev->addr, mac_addr, sizeof(mac_dev->addr)); 732 ether_addr_copy(mac_dev->addr, mac_addr);
733 733
734 /* Get the port handles */ 734 /* Get the port handles */
735 nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL); 735 nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL);
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 90ea7a115d0f..5fad73b2e123 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -1015,7 +1015,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
1015 1015
1016 mac_addr = of_get_mac_address(ofdev->dev.of_node); 1016 mac_addr = of_get_mac_address(ofdev->dev.of_node);
1017 if (!IS_ERR(mac_addr)) 1017 if (!IS_ERR(mac_addr))
1018 memcpy(ndev->dev_addr, mac_addr, ETH_ALEN); 1018 ether_addr_copy(ndev->dev_addr, mac_addr);
1019 1019
1020 ret = fep->ops->allocate_bd(ndev); 1020 ret = fep->ops->allocate_bd(ndev);
1021 if (ret) 1021 if (ret)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index df13c693b038..e670cd293dba 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -873,7 +873,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
873 mac_addr = of_get_mac_address(np); 873 mac_addr = of_get_mac_address(np);
874 874
875 if (!IS_ERR(mac_addr)) 875 if (!IS_ERR(mac_addr))
876 memcpy(dev->dev_addr, mac_addr, ETH_ALEN); 876 ether_addr_copy(dev->dev_addr, mac_addr);
877 877
878 if (model && !strcasecmp(model, "TSEC")) 878 if (model && !strcasecmp(model, "TSEC"))
879 priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT | 879 priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 216e99af2b5a..4d6892d2f0a4 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3911,7 +3911,7 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3911 3911
3912 mac_addr = of_get_mac_address(np); 3912 mac_addr = of_get_mac_address(np);
3913 if (!IS_ERR(mac_addr)) 3913 if (!IS_ERR(mac_addr))
3914 memcpy(dev->dev_addr, mac_addr, ETH_ALEN); 3914 ether_addr_copy(dev->dev_addr, mac_addr);
3915 3915
3916 ugeth->ug_info = ug_info; 3916 ugeth->ug_info = ug_info;
3917 ugeth->dev = device; 3917 ugeth->dev = device;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 07e254fc96ef..409b69fd4374 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2750,7 +2750,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
2750 2750
2751 mac_addr = of_get_mac_address(pnp); 2751 mac_addr = of_get_mac_address(pnp);
2752 if (!IS_ERR(mac_addr)) 2752 if (!IS_ERR(mac_addr))
2753 memcpy(ppd.mac_addr, mac_addr, ETH_ALEN); 2753 ether_addr_copy(ppd.mac_addr, mac_addr);
2754 2754
2755 mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size); 2755 mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size);
2756 mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr); 2756 mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr);
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 8186135883ed..e758650b2c26 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4565,7 +4565,7 @@ static int mvneta_probe(struct platform_device *pdev)
4565 dt_mac_addr = of_get_mac_address(dn); 4565 dt_mac_addr = of_get_mac_address(dn);
4566 if (!IS_ERR(dt_mac_addr)) { 4566 if (!IS_ERR(dt_mac_addr)) {
4567 mac_from = "device tree"; 4567 mac_from = "device tree";
4568 memcpy(dev->dev_addr, dt_mac_addr, ETH_ALEN); 4568 ether_addr_copy(dev->dev_addr, dt_mac_addr);
4569 } else { 4569 } else {
4570 mvneta_get_mac_addr(pp, hw_mac_addr); 4570 mvneta_get_mac_addr(pp, hw_mac_addr);
4571 if (is_valid_ether_addr(hw_mac_addr)) { 4571 if (is_valid_ether_addr(hw_mac_addr)) {
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 9d070cca3e9e..5adf307fbbfd 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4805,7 +4805,7 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
4805 */ 4805 */
4806 iap = of_get_mac_address(hw->pdev->dev.of_node); 4806 iap = of_get_mac_address(hw->pdev->dev.of_node);
4807 if (!IS_ERR(iap)) 4807 if (!IS_ERR(iap))
4808 memcpy(dev->dev_addr, iap, ETH_ALEN); 4808 ether_addr_copy(dev->dev_addr, iap);
4809 else 4809 else
4810 memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, 4810 memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
4811 ETH_ALEN); 4811 ETH_ALEN);
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index b44172a901ed..ba4fdf1b0dea 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -426,7 +426,7 @@ static void ks8851_init_mac(struct ks8851_net *ks)
426 426
427 mac_addr = of_get_mac_address(ks->spidev->dev.of_node); 427 mac_addr = of_get_mac_address(ks->spidev->dev.of_node);
428 if (!IS_ERR(mac_addr)) { 428 if (!IS_ERR(mac_addr)) {
429 memcpy(dev->dev_addr, mac_addr, ETH_ALEN); 429 ether_addr_copy(dev->dev_addr, mac_addr);
430 ks8851_write_mac_addr(dev); 430 ks8851_write_mac_addr(dev);
431 return; 431 return;
432 } 432 }
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index dc76b0d15234..e5c8412c08c1 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1328,7 +1328,7 @@ static int ks8851_probe(struct platform_device *pdev)
1328 if (pdev->dev.of_node) { 1328 if (pdev->dev.of_node) {
1329 mac = of_get_mac_address(pdev->dev.of_node); 1329 mac = of_get_mac_address(pdev->dev.of_node);
1330 if (!IS_ERR(mac)) 1330 if (!IS_ERR(mac))
1331 memcpy(ks->mac_addr, mac, ETH_ALEN); 1331 ether_addr_copy(ks->mac_addr, mac);
1332 } else { 1332 } else {
1333 struct ks8851_mll_platform_data *pdata; 1333 struct ks8851_mll_platform_data *pdata;
1334 1334
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index da138edddd32..fec604c4c0d3 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1369,7 +1369,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
1369 if (!is_valid_ether_addr(ndev->dev_addr)) { 1369 if (!is_valid_ether_addr(ndev->dev_addr)) {
1370 const char *macaddr = of_get_mac_address(np); 1370 const char *macaddr = of_get_mac_address(np);
1371 if (!IS_ERR(macaddr)) 1371 if (!IS_ERR(macaddr))
1372 memcpy(ndev->dev_addr, macaddr, ETH_ALEN); 1372 ether_addr_copy(ndev->dev_addr, macaddr);
1373 } 1373 }
1374 if (!is_valid_ether_addr(ndev->dev_addr)) 1374 if (!is_valid_ether_addr(ndev->dev_addr))
1375 eth_hw_addr_random(ndev); 1375 eth_hw_addr_random(ndev);
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 7c4e282242d5..6354f19a31eb 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3193,7 +3193,7 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
3193 3193
3194 mac_addr = of_get_mac_address(np); 3194 mac_addr = of_get_mac_address(np);
3195 if (!IS_ERR(mac_addr)) 3195 if (!IS_ERR(mac_addr))
3196 memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); 3196 ether_addr_copy(pdata->mac_addr, mac_addr);
3197 3197
3198 pdata->no_ether_link = 3198 pdata->no_ether_link =
3199 of_property_read_bool(np, "renesas,no-ether-link"); 3199 of_property_read_bool(np, "renesas,no-ether-link");
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index b18eeb05b993..634fc484a0b3 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2233,7 +2233,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2233no_phy_slave: 2233no_phy_slave:
2234 mac_addr = of_get_mac_address(slave_node); 2234 mac_addr = of_get_mac_address(slave_node);
2235 if (!IS_ERR(mac_addr)) { 2235 if (!IS_ERR(mac_addr)) {
2236 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); 2236 ether_addr_copy(slave_data->mac_addr, mac_addr);
2237 } else { 2237 } else {
2238 ret = ti_cm_get_macid(&pdev->dev, i, 2238 ret = ti_cm_get_macid(&pdev->dev, i,
2239 slave_data->mac_addr); 2239 slave_data->mac_addr);
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 997475c209c0..47c45152132e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -361,7 +361,7 @@ static void temac_do_set_mac_address(struct net_device *ndev)
361 361
362static int temac_init_mac_address(struct net_device *ndev, const void *address) 362static int temac_init_mac_address(struct net_device *ndev, const void *address)
363{ 363{
364 memcpy(ndev->dev_addr, address, ETH_ALEN); 364 ether_addr_copy(ndev->dev_addr, address);
365 if (!is_valid_ether_addr(ndev->dev_addr)) 365 if (!is_valid_ether_addr(ndev->dev_addr))
366 eth_hw_addr_random(ndev); 366 eth_hw_addr_random(ndev);
367 temac_do_set_mac_address(ndev); 367 temac_do_set_mac_address(ndev);
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 691170753563..6886270da695 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1167,7 +1167,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
1167 1167
1168 if (!IS_ERR(mac_address)) { 1168 if (!IS_ERR(mac_address)) {
1169 /* Set the MAC address. */ 1169 /* Set the MAC address. */
1170 memcpy(ndev->dev_addr, mac_address, ETH_ALEN); 1170 ether_addr_copy(ndev->dev_addr, mac_address);
1171 } else { 1171 } else {
1172 dev_warn(dev, "No MAC address found, using random\n"); 1172 dev_warn(dev, "No MAC address found, using random\n");
1173 eth_hw_addr_random(ndev); 1173 eth_hw_addr_random(ndev);