Skip to content

Commit b74ef9f

Browse files
nathanchancedavem330
authored andcommitted
net: sparx5: Do not use mac_addr uninitialized in mchp_sparx5_probe()
Clang warns: drivers/net/ethernet/microchip/sparx5/sparx5_main.c:760:29: warning: variable 'mac_addr' is uninitialized when used here [-Wuninitialized] if (of_get_mac_address(np, mac_addr)) { ^~~~~~~~ drivers/net/ethernet/microchip/sparx5/sparx5_main.c:669:14: note: initialize the variable 'mac_addr' to silence this warning u8 *mac_addr; ^ = NULL 1 warning generated. mac_addr is only used to store the value retrieved from of_get_mac_address(), which is then copied into the base_mac member of the sparx5 struct using ether_addr_copy(). It is easier to just use the base_mac address directly, which avoids the warning and the extra copy. Fixes: 3cfa11b ("net: sparx5: add the basic sparx5 driver") Link: ClangBuiltLinux#1413 Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 74e7fef commit b74ef9f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
670670
struct reset_control *reset;
671671
struct sparx5 *sparx5;
672672
int idx = 0, err = 0;
673-
u8 *mac_addr;
674673

675674
if (!np && !pdev->dev.platform_data)
676675
return -ENODEV;
@@ -761,12 +760,10 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
761760
if (err)
762761
goto cleanup_config;
763762

764-
if (of_get_mac_address(np, mac_addr)) {
763+
if (!of_get_mac_address(np, sparx5->base_mac)) {
765764
dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n");
766765
eth_random_addr(sparx5->base_mac);
767766
sparx5->base_mac[5] = 0;
768-
} else {
769-
ether_addr_copy(sparx5->base_mac, mac_addr);
770767
}
771768

772769
sparx5->xtr_irq = platform_get_irq_byname(sparx5->pdev, "xtr");

0 commit comments

Comments
 (0)