]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ixgbe: fix crash with empty VF macvlan list
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 6 Oct 2023 12:53:09 +0000 (15:53 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 09:13:30 +0000 (11:13 +0200)
[ Upstream commit 7b5add9af567c44e12196107f0fe106e194034fd ]

The adapter->vf_mvs.l list needs to be initialized even if the list is
empty.  Otherwise it will lead to crashes.

Fixes: a1cbb15c1397 ("ixgbe: Add macvlan support for VF")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Link: https://lore.kernel.org/r/ZSADNdIw8zFx1xw2@kadam
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

index f36bb9e7d8d59d109c432a9fa15a0df681922da2..3698c45837d82cb924f4e4863027616fc19c2831 100644 (file)
@@ -53,6 +53,9 @@ static inline void ixgbe_alloc_vf_macvlans(struct ixgbe_adapter *adapter,
        struct vf_macvlans *mv_list;
        int num_vf_macvlans, i;
 
+       /* Initialize list of VF macvlans */
+       INIT_LIST_HEAD(&adapter->vf_mvs.l);
+
        num_vf_macvlans = hw->mac.num_rar_entries -
                          (IXGBE_MAX_PF_MACVLANS + 1 + num_vfs);
        if (!num_vf_macvlans)
@@ -61,8 +64,6 @@ static inline void ixgbe_alloc_vf_macvlans(struct ixgbe_adapter *adapter,
        mv_list = kcalloc(num_vf_macvlans, sizeof(struct vf_macvlans),
                          GFP_KERNEL);
        if (mv_list) {
-               /* Initialize list of VF macvlans */
-               INIT_LIST_HEAD(&adapter->vf_mvs.l);
                for (i = 0; i < num_vf_macvlans; i++) {
                        mv_list[i].vf = -1;
                        mv_list[i].free = true;