From nobody Wed Dec 31 10:32:50 2025 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 40E90C4332F for ; Fri, 3 Nov 2023 20:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbjKCUnU (ORCPT ); Fri, 3 Nov 2023 16:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKCUnS (ORCPT ); Fri, 3 Nov 2023 16:43:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B11E5A2 for ; Fri, 3 Nov 2023 13:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699044145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pzoYxr3bqaj9J8o6w9KSItY5CaVEMiyYip8XBCOjU7A=; b=iMlEO8XaJpMfnc1bmD+e8O3sx+zkL98H1ZBDofPDJAeQNVLtvaQuQUGGihy/5z7GlhQnXW IzBcBtQ0kCwYI4tI4MoR548fvnS5Sk7MF+hwDo5zV1BhYJQ3c/3NbMFyMZJOA1ZnhdYU8c 0JSbGbTAb1tupU+7MqSMa1MtpIPsAsU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-GCm0XO-jMfWFr0uynWPCMA-1; Fri, 03 Nov 2023 16:42:20 -0400 X-MC-Unique: GCm0XO-jMfWFr0uynWPCMA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22D5C101A529; Fri, 3 Nov 2023 20:42:20 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.224.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E5D51121309; Fri, 3 Nov 2023 20:42:17 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, Jacob Keller , Wojciech Drewek Subject: [PATCH net] i40e: Fix adding unsupported cloud filters Date: Fri, 3 Nov 2023 21:42:16 +0100 Message-ID: <20231103204216.1072251-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If a VF tries to add unsupported cloud filter through virchnl then i40e_add_del_cloud_filter(_big_buf) returns -ENOTSUPP but this error code is stored in 'ret' instead of 'aq_ret' that is used as error code sent back to VF. In this scenario where one of the mentioned functions fails the value of 'aq_ret' is zero so the VF will incorrectly receive a 'success'. Use 'aq_ret' to store return value and remove 'ret' local variable. Additionally fix the issue when filter allocation fails, in this case no notification is sent back to the VF. Signed-off-by: Ivan Vecera Reviewed-by: Simon Horman --- .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/n= et/ethernet/intel/i40e/i40e_virtchnl_pf.c index 08d7edccfb8ddb..3f99eb19824527 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -3844,7 +3844,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *v= f, u8 *msg) struct i40e_pf *pf =3D vf->pf; struct i40e_vsi *vsi =3D NULL; int aq_ret =3D 0; - int i, ret; + int i; =20 if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { aq_ret =3D -EINVAL; @@ -3868,8 +3868,10 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *= vf, u8 *msg) } =20 cfilter =3D kzalloc(sizeof(*cfilter), GFP_KERNEL); - if (!cfilter) - return -ENOMEM; + if (!cfilter) { + aq_ret =3D -ENOMEM; + goto err_out; + } =20 /* parse destination mac address */ for (i =3D 0; i < ETH_ALEN; i++) @@ -3917,13 +3919,13 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf = *vf, u8 *msg) =20 /* Adding cloud filter programmed as TC filter */ if (tcf.dst_port) - ret =3D i40e_add_del_cloud_filter_big_buf(vsi, cfilter, true); + aq_ret =3D i40e_add_del_cloud_filter_big_buf(vsi, cfilter, true); else - ret =3D i40e_add_del_cloud_filter(vsi, cfilter, true); - if (ret) { + aq_ret =3D i40e_add_del_cloud_filter(vsi, cfilter, true); + if (aq_ret) { dev_err(&pf->pdev->dev, "VF %d: Failed to add cloud filter, err %pe aq_err %s\n", - vf->vf_id, ERR_PTR(ret), + vf->vf_id, ERR_PTR(aq_ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); goto err_free; } --=20 2.41.0