From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1E9FC433FE for ; Wed, 24 Nov 2021 13:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344258AbhKXNR3 (ORCPT ); Wed, 24 Nov 2021 08:17:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:57982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348781AbhKXNOC (ORCPT ); Wed, 24 Nov 2021 08:14:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6CB361AA4; Wed, 24 Nov 2021 12:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637757827; bh=D5prBRVHoRoICqucyomoCUZB+edbO/DzreDSY6iKGDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bvV2fOQxtKt2UUsIRDCiBpp1Kmg4G3RvgoZ4N6Ro9WOAJzska89LWEj9cL/bWMXkT 7pzeOgJcqJnm1nzx6GSib5mDoa2i+zPfR21igt1N5qXIfUGA5WqZlUthW6XBAT+Wqh KA1a791sTE3Ybn50HzYQtEzWmV/h+yegF74/2vqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Nunley , Tony Brelinski , Tony Nguyen , Sasha Levin Subject: [PATCH 4.19 288/323] iavf: check for null in iavf_fix_features Date: Wed, 24 Nov 2021 12:57:58 +0100 Message-Id: <20211124115728.624581935@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115718.822024889@linuxfoundation.org> References: <20211124115718.822024889@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Nunley [ Upstream commit 8a4a126f4be88eb8b5f00a165ab58c35edf4ef76 ] If the driver has lost contact with the PF then it enters a disabled state and frees adapter->vf_res. However, ndo_fix_features can still be called on the interface, so we need to check for this condition first. Since we have no information on the features at this time simply leave them unmodified and return. Fixes: c4445aedfe09 ("i40evf: Fix VLAN features") Signed-off-by: Nicholas Nunley Tested-by: Tony Brelinski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c index ac5709624c7ad..1fd8cc5ac306c 100644 --- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c +++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c @@ -3185,7 +3185,8 @@ static netdev_features_t i40evf_fix_features(struct net_device *netdev, { struct i40evf_adapter *adapter = netdev_priv(netdev); - if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)) + if (adapter->vf_res && + !(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)) features &= ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER); -- 2.33.0