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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5FA3D2F7E9 for ; Thu, 17 Oct 2024 03:51:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 32A78606B3; Thu, 17 Oct 2024 03:51:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id z1rQL8O_ozDJ; Thu, 17 Oct 2024 03:51:57 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6098D606BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1729137117; bh=Am7z/ewwRU7URpH1zeuXH9BvU8ZEygj12hlGHqnqVmE=; h=Date:To:CC:References:From:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ei56zOhEFUazxE1/27jthA+oSszk/FyGU2721+fkpQh0XYMA7e26N7yqkTivcVa36 V007mIb6ihCQV0Mqyfdm28cRAK2AlzQgiRmQFKy0Z/uwsYVTVhLJzBdlpQi2A8QQj9 DHc/jugiEijvL9ZZN16ynvPzJmMBH5Rz9RemMe/V506RooskAZc3mom36QlqKJhley 54U93GeaqbTsakhU2kX8DjfIesbC7xtfbl7/3uTuqWnYih/zn6lP8NRaI9BsQnlOAC pifbwhQ+iIFb+ZhTFlL65Eql6aMhQK7jXDgDfsV5D7TJNuL1TcKV2MipCKKqDIj+k4 ueorgKQS9l+oQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 6098D606BD; Thu, 17 Oct 2024 03:51:57 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 20A142316 for ; Thu, 17 Oct 2024 03:51:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EEC2480EB9 for ; Thu, 17 Oct 2024 03:51:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 44B1t7_DO1qR for ; Thu, 17 Oct 2024 03:51:54 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=45.249.212.191; helo=szxga05-in.huawei.com; envelope-from=yuehaibing@huawei.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 3FE1180E90 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3FE1180E90 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3FE1180E90 for ; Thu, 17 Oct 2024 03:51:52 +0000 (UTC) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XTYlC605hz1j9v8; Thu, 17 Oct 2024 11:50:31 +0800 (CST) Received: from dggpemf500002.china.huawei.com (unknown [7.185.36.57]) by mail.maildlp.com (Postfix) with ESMTPS id C47291A0188; Thu, 17 Oct 2024 11:51:46 +0800 (CST) Received: from [10.174.179.113] (10.174.179.113) by dggpemf500002.china.huawei.com (7.185.36.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 17 Oct 2024 11:51:45 +0800 Message-ID: <4d80b2fd-17d8-a7bd-0e80-7d33c9764810@huawei.com> Date: Thu, 17 Oct 2024 11:51:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Content-Language: en-US To: Jacob Keller , Simon Horman CC: , , , , , , , , , , , , , , , , , References: <20241016105310.3500279-1-yuehaibing@huawei.com> <20241016185333.GL2162@kernel.org> <8e4ef7f6-1d7d-45dc-b26e-4d9bc37269de@intel.com> From: Yue Haibing In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.113] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf500002.china.huawei.com (7.185.36.57) X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Subject: Re: [Intel-wired-lan] [PATCH net] igc: Fix passing 0 to ERR_PTR in igc_xdp_run_prog() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On 2024/10/17 7:12, Jacob Keller wrote: > > > On 10/16/2024 4:06 PM, Jacob Keller wrote: >> >> >> On 10/16/2024 11:53 AM, Simon Horman wrote: >>> On Wed, Oct 16, 2024 at 06:53:10PM +0800, Yue Haibing wrote: >>>> Return NULL instead of passing to ERR_PTR while res is IGC_XDP_PASS, >>>> which is zero, this fix smatch warnings: >>>> drivers/net/ethernet/intel/igc/igc_main.c:2533 >>>> igc_xdp_run_prog() warn: passing zero to 'ERR_PTR' >>>> >>>> Fixes: 26575105d6ed ("igc: Add initial XDP support") >>>> Signed-off-by: Yue Haibing >>>> --- >>>> drivers/net/ethernet/intel/igc/igc_main.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c >>>> index 6e70bca15db1..c3d6e20c0be0 100644 >>>> --- a/drivers/net/ethernet/intel/igc/igc_main.c >>>> +++ b/drivers/net/ethernet/intel/igc/igc_main.c >>>> @@ -2530,7 +2530,7 @@ static struct sk_buff *igc_xdp_run_prog(struct igc_adapter *adapter, >>>> res = __igc_xdp_run_prog(adapter, prog, xdp); >>>> >>>> out: >>>> - return ERR_PTR(-res); >>>> + return res ? ERR_PTR(-res) : NULL; >>> >>> I think this is what PTR_ERR_OR_ZERO() is for. >> >> Not quite. PTR_ERR_OR_ZERO is intended for the case where you are >> extracting an error from a pointer. This is converting an error into a >> pointer. >> >> I am not sure what is really expected here. If res is zero, shouldn't we >> be returning an skb pointer and not NULL? >> >> Why does igc_xdp_run_prog even return a sk_buff pointer at all? It never >> actually returns an skb... >> >> This feels like the wrong fix entirely. >> >> __igc_xdp_run_prog returns a custom value for the action, between >> IGC_XDP_PASS, IGC_XDP_TX, IGC_XDP_REDIRECT, or IGC_XDP_CONSUMED. >> >> This function is called by igc_xdp_run_prog which converts this to a >> negative error code with the sk_buff pointer type. >> >> All so that we can assign a value to the skb pointer in >> ice_clean_rx_irq, and check it with IS_ERR >> >> I don't like this fix, I think we could drop the igc_xdp_run_prog >> wrapper, call __igc_xdp_run_prog directly and check its return value >> instead of this method of using an error pointer. > > Indeed, this SKB error stuff was added by 26575105d6ed ("igc: Add > initial XDP support") which claims to be aligning with other Intel drivers. > > But the other Intel drivers just have a function that returns the xdp > result and checks it directly. >Thanks for review,maybe can fix this as commit 12738ac4754e ("i40e: Fix sparse errors in i40e_txrx.c")? > Perhaps this is due to the way that the igc driver shares rings between > XDP and the regular path? > > Its not clear to me, but I think this fix is not what I would do. > > .