The branch stable/13 has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=18e4cb41e945a79afabb8fa82fe39f28865aa3cf

commit 18e4cb41e945a79afabb8fa82fe39f28865aa3cf
Author:     Zhenlei Huang <[email protected]>
AuthorDate: 2026-02-06 17:52:53 +0000
Commit:     Zhenlei Huang <[email protected]>
CommitDate: 2026-02-24 10:15:35 +0000

    qlnxe: Avoid memcpy with same source and destination
    
    In case the device is VF, qlnx_get_mac_addr() returns ha->primary_mac
    hence it ends up memcpy with same source and destination. Refactor
    slightly to avoid that.
    
    Reviewed by:    kbowling
    MFC after:      5 days
    Differential Revision:  https://reviews.freebsd.org/D54884
    
    (cherry picked from commit 3aeeedc7e0dc231c16406ff64f4a08a716964c40)
    (cherry picked from commit 6462189595047800337aaf052e397d1aade3f9a7)
    (cherry picked from commit ea1143bddbc3671f49219a6b2a054965deea0c63)
---
 sys/dev/qlnx/qlnxe/qlnx_def.h |  1 -
 sys/dev/qlnx/qlnxe/qlnx_os.c  | 13 +++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/qlnx/qlnxe/qlnx_def.h b/sys/dev/qlnx/qlnxe/qlnx_def.h
index 898d85fdba89..3e63bd2d1882 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_def.h
+++ b/sys/dev/qlnx/qlnxe/qlnx_def.h
@@ -683,7 +683,6 @@ extern int qlnx_grc_dump(qlnx_host_t *ha, uint32_t 
*num_dumped_dwords,
                int hwfn_index);
 extern int qlnx_idle_chk(qlnx_host_t *ha, uint32_t *num_dumped_dwords,
                int hwfn_index);
-extern uint8_t *qlnx_get_mac_addr(qlnx_host_t *ha);
 extern void qlnx_fill_link(qlnx_host_t *ha, struct ecore_hwfn *hwfn,
                           struct qlnx_link_output *if_link);
 extern int qlnx_set_lldp_tlvx(qlnx_host_t *ha, qlnx_lldp_sys_tlvs_t 
*lldp_tlvs);
diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c
index 64909d39ff59..a9acfffee629 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_os.c
+++ b/sys/dev/qlnx/qlnxe/qlnx_os.c
@@ -94,6 +94,7 @@ static void qlnx_stop(qlnx_host_t *ha);
 static int qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp,
                struct mbuf **m_headp);
 static int qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha);
+static void qlnx_get_mac_addr(qlnx_host_t *ha);
 static uint32_t qlnx_get_optics(qlnx_host_t *ha,
                        struct qlnx_link_output *if_link);
 static int qlnx_transmit(struct ifnet *ifp, struct mbuf  *mp);
@@ -2369,7 +2370,7 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha)
 
         ha->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
 
-        memcpy(ha->primary_mac, qlnx_get_mac_addr(ha), ETH_ALEN);
+       qlnx_get_mac_addr(ha);
 
        if (!ha->primary_mac[0] && !ha->primary_mac[1] &&
                !ha->primary_mac[2] && !ha->primary_mac[3] &&
@@ -3835,7 +3836,7 @@ qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha)
         return(TX_RING_SIZE - 1);
 }
 
-uint8_t *
+static void
 qlnx_get_mac_addr(qlnx_host_t *ha)
 {
        struct ecore_hwfn       *p_hwfn;
@@ -3844,8 +3845,10 @@ qlnx_get_mac_addr(qlnx_host_t *ha)
 
        p_hwfn = &ha->cdev.hwfns[0];
 
-       if (qlnx_vf_device(ha) != 0) 
-               return (p_hwfn->hw_info.hw_mac_addr);
+       if (qlnx_vf_device(ha) != 0) {
+               memcpy(ha->primary_mac, p_hwfn->hw_info.hw_mac_addr, ETH_ALEN);
+               return;
+       }
 
        ecore_vf_read_bulletin(p_hwfn, &p_is_forced);
        if (ecore_vf_bulletin_get_forced_mac(p_hwfn, mac, &p_is_forced) ==
@@ -3855,8 +3858,6 @@ qlnx_get_mac_addr(qlnx_host_t *ha)
                        p_is_forced, mac[0], mac[1], mac[2], mac[3], mac[4], 
mac[5]);
                memcpy(ha->primary_mac, mac, ETH_ALEN);
        }
-
-       return (ha->primary_mac);
 }
 
 static uint32_t

Reply via email to