Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1552358pxb; Fri, 6 Nov 2020 12:43:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8gAg32cZQdqCpgAwr1bSlyZR+7HA1NAC+GPfOsuZ0dI2iwg6gDYZjsq1AilS87rz0Fk7s X-Received: by 2002:a17:906:349b:: with SMTP id g27mr4034569ejb.512.1604695384724; Fri, 06 Nov 2020 12:43:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604695384; cv=none; d=google.com; s=arc-20160816; b=qXswUgUmqvjpKIvzgHz89SMzPwawaIQMw1kfLVSHHj2J2qGTzQ/EttoYKpbhr79m8y KvtTcB8Z2FpASeKF091HfrmAeszjrbGjyW0c8LIYFIm1LN+67HgnQHSdxgl3bOU4zVOm zD7bg0rMg+h10crpbxJpTUHfiIwBoVORziZiVgikcGX//s0XUyjiQKAQxzvTqMCArafN 4CFy//LXY9tjaGX6Y/92ryuVUE/i9DKYMcdOlY/vCH0XTiroJOUQpTSZejScfIS4hYYI arVDUw6YPW2MgD9mF/5qoGnrDUhPZAavwL/um6D0OISJDatQauyYzw8wq6zZtoZ3rQPW txqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NXrpuCgbHGPkXrL8EDCTVatq79k2biAMrH6DnCMYtLg=; b=t1bX3YYmZ2GFi/BfaaZPIBS+fDZNETnxKQ3/v3ua0aMMc3ioef2AAsQoBFTioSxChL xdFYDr9pTu0b/qiqoLBbYZyoBZRYpAd7DR17VBN/YBJTyxA+Vg3w0Bt0DJ62DHI0arjx GU0vV6s3Iv/Vfy17MkcgqDPWRx7SjlIvCbcRb/QbSOdfGTLPbR8yDhBrecwyUnYaYoJP qlecgHf2rKWpUCKfjsirkibNu+OJQqCakzjlx7vQ6h3ivP/S+WXY+uQo3s/p3s8ZCxv+ C77FtUGX500DqaUZeG4t/r5FrkRr/qN8n2T8WO5tIqrEv6NcThmQH/7pJR1MmAFrvRnn 0hBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="imytYR+/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si1733195ejo.131.2020.11.06.12.42.41; Fri, 06 Nov 2020 12:43:04 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="imytYR+/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728480AbgKFUlP (ORCPT + 99 others); Fri, 6 Nov 2020 15:41:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbgKFUlP (ORCPT ); Fri, 6 Nov 2020 15:41:15 -0500 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21262C0613CF; Fri, 6 Nov 2020 12:41:15 -0800 (PST) Received: by mail-yb1-xb44.google.com with SMTP id g15so2266907ybq.6; Fri, 06 Nov 2020 12:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NXrpuCgbHGPkXrL8EDCTVatq79k2biAMrH6DnCMYtLg=; b=imytYR+/gxZRffg9Cg6cnS88WCEJguY/eo7kl+jiw9eXJ3Jag+Zs4/oNRMs5+Rp/q7 l6RT+REDAL6ujAwTtSEkQlyohkvsLq0NQUFqHg/d9u8KAc22yqq3R8dM+eYCXSELmoo6 MrLVZyBmYcLpfXV0ppMyM8tnDa61vXK1O4NtMiJDBSCgHG/kszG4Uz2RQ6zj3EDTr95M H4ya9dwPhip/LaXw7xjTaxrHxSKDSUvu/ZEOChFT85b5K/TNYNtacV3IkYV3Bdp+HJan mf+JuozlI6c7p68MqcG1hlUO3Id5+R/MDQacy9rIiXC7wkixrXoUjs7F4fkrItWFJGMV aipw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NXrpuCgbHGPkXrL8EDCTVatq79k2biAMrH6DnCMYtLg=; b=MAe4zIqxS4Kqax0R0OHqjZXDqHg6TFOYtlXBG8xktsdkMPFuhQ44tn71GfgtOGnHLY dutMpxY4xItCa9ovd5+44Hnq83+nASEEGpRjimEKMxNte0j92Hxmp9BRklXXqwtvXQn1 QmyuIGhKT5qTXxAA0ZCoDmr76ruk3D92til3IbCufpf4wMi5xdBqY0ixw092DR/mlC4K 5eqYF6i2/1tUpYAgyRX1cedvtNWTVMHeFvLzKdS++n9vPcXwP7WoJ8U8mTo31I3BCokn v26qVHSKPB6ju9IHKnPElN/zTZRuqVT3CTUyiH170EnSxTD+WD+unFRrrBEhzlqrVXTZ K9Lw== X-Gm-Message-State: AOAM531SLgiY69t5S4WZSIKg6KTkqIY/wRNgF2DJDIGiltKiKUZwhijZ /GCWFmUkfA/S9M/7sy/XRwJY/2CHohtsSIag/80= X-Received: by 2002:a25:b0d:: with SMTP id 13mr5337996ybl.347.1604695274441; Fri, 06 Nov 2020 12:41:14 -0800 (PST) MIME-Version: 1.0 References: <1604652452-11494-1-git-send-email-wangqing@vivo.com> In-Reply-To: <1604652452-11494-1-git-send-email-wangqing@vivo.com> From: Andrii Nakryiko Date: Fri, 6 Nov 2020 12:41:03 -0800 Message-ID: Subject: Re: [PATCH] trace: Fix passing zero to 'PTR_ERR' warning To: Wang Qing Cc: Steven Rostedt , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 6, 2020 at 12:49 AM Wang Qing wrote: > > Fix smatch warning. > > Signed-off-by: Wang Qing > --- > kernel/trace/bpf_trace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index 4517c8b..2cb9c45 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -1198,7 +1198,7 @@ static int bpf_btf_printf_prepare(struct btf_ptr *ptr, u32 btf_ptr_size, > *btf = bpf_get_btf_vmlinux(); > > if (IS_ERR_OR_NULL(*btf)) > - return PTR_ERR(*btf); > + return PTR_ERR_OR_ZERO(*btf); Either way returns zero for error? Which is the actual bug, so I think the proper fix is: return *btf ? PTR_ERR(*btf) : -EINVAL; Or something like that. > > if (ptr->type_id > 0) > *btf_id = ptr->type_id; > -- > 2.7.4 >