Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp727770pxj; Fri, 28 May 2021 14:15:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6r5aCRCPdbXhkt75hW70IovcPL+qUuaEhPyG7XFQZS5UcP6XUfBJRGdJmHjyUsYB6YrC/ X-Received: by 2002:a5d:8f81:: with SMTP id l1mr8221694iol.115.1622236558467; Fri, 28 May 2021 14:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622236558; cv=none; d=google.com; s=arc-20160816; b=x55zLmv2NC2CLH3/WI63XwEAymyQQX6sFPOcZ5xe1ueRsjouUYzG/qzCDjPuuVf3wU HbJ03dBvcczQ675ldETmh9lkczzjNEI92VTxZ+ezotmQSDEv0ilDpJ72y5TMFlCplL4G jhxAtmLvWFLIB9IrA3Zh3sw/dUcwEAfRO5zBamjM9AkmpLXnpMnxZUWz6LJXBqt63UbY 5XsHUj2gSdRaffWWpD0PWs/tFzIr5T9yEyJQTpdmJoH4Y398Tk8JFVM+OuoLL9NWz5VA JN+/H4clQUnP/Pm8tQXo2KutPiF+qzpDfsF13iNAtfDEnaB7tM1YNzWb1g1gHVY1jFro DMTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=kYUeNisaUpNxDf0yjm1z4sdipY6sAP7Yt6dx8Pj1InI=; b=Jw/taEmlXjiWn5EabCvNiw8d1VPV4PxW6m80xBvgqgFuTtqwui68EkpqxKtcxcj3rm X6CEPAYtaMZJ8HK0bKXyualWS48nIIbgj2QsEEzYUjZV2LuoniDm96M1FIZ8QOuMY2CC jZzM5KjzEgkWgx1L1fhHegAtdKYA+uvitqv58GjqBu0ho2H0UPNs4Uwf4HzfhMgW+8J2 9Mxk24V5N/SwrbCUwAFxjjTgHIt0x2sHOlwBv+RwNU93VSy1aLPUc9Wh84rUKlF3rSOP NgqprB6pc0nfUlbeYrxbv3LZIOFFTnDk/bECDLs3V6ooiD9TmJij0h0SbtAMFMSYGG9z m8+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si7126978ile.24.2021.05.28.14.15.43; Fri, 28 May 2021 14:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbhE1VPV (ORCPT + 99 others); Fri, 28 May 2021 17:15:21 -0400 Received: from www62.your-server.de ([213.133.104.62]:41710 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhE1VPU (ORCPT ); Fri, 28 May 2021 17:15:20 -0400 Received: from sslproxy03.your-server.de ([88.198.220.132]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lmjNA-0000UR-78; Fri, 28 May 2021 22:46:24 +0200 Received: from [85.7.101.30] (helo=linux.home) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lmjNA-000JT2-0a; Fri, 28 May 2021 22:46:24 +0200 Subject: Re: [PATCH] selftests/bpf: Fix return value check in attach_bpf() To: Yu Kuai , shuah@kernel.org, ast@kernel.org, andrii@kernel.org Cc: linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com References: <20210528090758.1108464-1-yukuai3@huawei.com> From: Daniel Borkmann Message-ID: Date: Fri, 28 May 2021 22:46:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20210528090758.1108464-1-yukuai3@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.2/26184/Fri May 28 13:05:50 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/21 11:07 AM, Yu Kuai wrote: > use libbpf_get_error() to check the return value of > bpf_program__attach(). > > Reported-by: Hulk Robot > Signed-off-by: Yu Kuai > --- > tools/testing/selftests/bpf/benchs/bench_rename.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/benchs/bench_rename.c b/tools/testing/selftests/bpf/benchs/bench_rename.c > index c7ec114eca56..b7d4a1d74fca 100644 > --- a/tools/testing/selftests/bpf/benchs/bench_rename.c > +++ b/tools/testing/selftests/bpf/benchs/bench_rename.c > @@ -65,7 +65,7 @@ static void attach_bpf(struct bpf_program *prog) > struct bpf_link *link; > > link = bpf_program__attach(prog); > - if (!link) { > + if (libbpf_get_error(link)) { > fprintf(stderr, "failed to attach program!\n"); > exit(1); > } Could you explain the rationale of this patch? bad2e478af3b ("selftests/bpf: Turn on libbpf 1.0 mode and fix all IS_ERR checks") explains: 'Fix all the explicit IS_ERR checks that now will be broken because libbpf returns NULL on error (and sets errno).' So the !link check looks totally reasonable to me. Converting to libbpf_get_error() is not wrong in itself, but given you don't make any use of the err code, there is also no point in this diff here. Thanks, Daniel