Skip to content

Commit db586ca

Browse files
keesPaolo Abeni
authored andcommitted
net/ncsi: Use struct sockaddr_storage for pending_mac
To avoid future casting with coming API type changes, switch struct ncsi_dev_priv::pending_mac to a full struct sockaddr_storage. Acked-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1619726 commit db586ca

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

net/ncsi/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ struct ncsi_dev_priv {
322322
#define NCSI_DEV_RESHUFFLE 4
323323
#define NCSI_DEV_RESET 8 /* Reset state of NC */
324324
unsigned int gma_flag; /* OEM GMA flag */
325-
struct sockaddr pending_mac; /* MAC address received from GMA */
325+
struct sockaddr_storage pending_mac; /* MAC address received from GMA */
326326
spinlock_t lock; /* Protect the NCSI device */
327327
unsigned int package_probe_id;/* Current ID during probe */
328328
unsigned int package_num; /* Number of packages */

net/ncsi/ncsi-manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
10581058
break;
10591059
case ncsi_dev_state_config_apply_mac:
10601060
rtnl_lock();
1061-
ret = dev_set_mac_address(dev, &ndp->pending_mac, NULL);
1061+
ret = dev_set_mac_address(dev, (struct sockaddr *)&ndp->pending_mac, NULL);
10621062
rtnl_unlock();
10631063
if (ret < 0)
10641064
netdev_warn(dev, "NCSI: 'Writing MAC address to device failed\n");

net/ncsi/ncsi-rsp.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr)
628628
static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id)
629629
{
630630
struct ncsi_dev_priv *ndp = nr->ndp;
631-
struct sockaddr *saddr = &ndp->pending_mac;
631+
struct sockaddr_storage *saddr = &ndp->pending_mac;
632632
struct net_device *ndev = ndp->ndev.dev;
633633
struct ncsi_rsp_oem_pkt *rsp;
634634
u32 mac_addr_off = 0;
@@ -644,11 +644,11 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id)
644644
else if (mfr_id == NCSI_OEM_MFR_INTEL_ID)
645645
mac_addr_off = INTEL_MAC_ADDR_OFFSET;
646646

647-
saddr->sa_family = ndev->type;
648-
memcpy(saddr->sa_data, &rsp->data[mac_addr_off], ETH_ALEN);
647+
saddr->ss_family = ndev->type;
648+
memcpy(saddr->__data, &rsp->data[mac_addr_off], ETH_ALEN);
649649
if (mfr_id == NCSI_OEM_MFR_BCM_ID || mfr_id == NCSI_OEM_MFR_INTEL_ID)
650-
eth_addr_inc((u8 *)saddr->sa_data);
651-
if (!is_valid_ether_addr((const u8 *)saddr->sa_data))
650+
eth_addr_inc(saddr->__data);
651+
if (!is_valid_ether_addr(saddr->__data))
652652
return -ENXIO;
653653

654654
/* Set the flag for GMA command which should only be called once */
@@ -1088,7 +1088,7 @@ static int ncsi_rsp_handler_netlink(struct ncsi_request *nr)
10881088
static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr)
10891089
{
10901090
struct ncsi_dev_priv *ndp = nr->ndp;
1091-
struct sockaddr *saddr = &ndp->pending_mac;
1091+
struct sockaddr_storage *saddr = &ndp->pending_mac;
10921092
struct net_device *ndev = ndp->ndev.dev;
10931093
struct ncsi_rsp_gmcma_pkt *rsp;
10941094
int i;
@@ -1105,15 +1105,15 @@ static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr)
11051105
rsp->addresses[i][4], rsp->addresses[i][5]);
11061106
}
11071107

1108-
saddr->sa_family = ndev->type;
1108+
saddr->ss_family = ndev->type;
11091109
for (i = 0; i < rsp->address_count; i++) {
11101110
if (!is_valid_ether_addr(rsp->addresses[i])) {
11111111
netdev_warn(ndev, "NCSI: Unable to assign %pM to device\n",
11121112
rsp->addresses[i]);
11131113
continue;
11141114
}
1115-
memcpy(saddr->sa_data, rsp->addresses[i], ETH_ALEN);
1116-
netdev_warn(ndev, "NCSI: Will set MAC address to %pM\n", saddr->sa_data);
1115+
memcpy(saddr->__data, rsp->addresses[i], ETH_ALEN);
1116+
netdev_warn(ndev, "NCSI: Will set MAC address to %pM\n", saddr->__data);
11171117
break;
11181118
}
11191119

0 commit comments

Comments
 (0)