Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2097122imm; Wed, 16 May 2018 07:51:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr5ocXDZkdaMxMNvC9d00qJx/hWKn+U5IEBmJhSUh1kBUapkO3yQzJkdJEWxOkOI0ixz07o X-Received: by 2002:a17:902:7d87:: with SMTP id a7-v6mr1317017plm.264.1526482310252; Wed, 16 May 2018 07:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526482310; cv=none; d=google.com; s=arc-20160816; b=wa3GTuq3lEzhtFNtDwJpubm0RTHOhO5Y4Cfj2duPj2/nZS62BKbcYxScyledHebjDf c1TS//dJnxMiWmC5NYxysk/lK+G/28y+6lqCs0s38t/B82uAWo1d9j1L3Bqz87sA6VJJ uTRy+cLkzpJWuhkoSkgSnuBL+F/nI1tx/qQ8H94t52+A3nP1yL1wmw+BNjSEYpTD7LEP 56O5V5D6eWXt+w6LLYFOUVUvnExtBJALblZZbXIEQkQFS6Dl1moaBa9cy6GMEz08WjJm bogUUcG8np0oOqOMkNkDR1QiKls16baJxgLl75i5N0D5fWMQhIXXBvI/TUc042kg0KBt tEqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Hm0Vfi4llHRECp11Ag4TrfCYetyc95vyASb77xw20D0=; b=bwg6OcZ7FD62BDjN9iCSC4s8iY9s2Xs7ZEnt16Y3gcIKcW8UWMYPsR+fbjZYs5bXBd GRe+popEVNyvOlKIcgAOa563wpxCEdT0G7nxnPCfx0gkEjhyMoZOUdBumuUPRdlCpb7d vYNn01C7v2kt1RD39n9TMGaII0p1A0axiMCiVf0AUxbdLA7qygai7WXhjhRhgo7LlkZO Vh5wvh7xzDJGj3ApEW+pBvb5Jm8sGMhF8vX33nQ/a9GV4DqiC3D1SWrlpUeDBENy08pF uzPKtVFUKPz8stPw5g8xJ0I42FJusE+tNFHCX0NrCbUo3Fxm4+KYP4rTvCFhuCz+kpIu 8D6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iAfKRsPG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si2112472pgn.187.2018.05.16.07.51.36; Wed, 16 May 2018 07:51:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iAfKRsPG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752189AbeEPOuD (ORCPT + 99 others); Wed, 16 May 2018 10:50:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:46262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbeEPOt6 (ORCPT ); Wed, 16 May 2018 10:49:58 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA1FE2083D; Wed, 16 May 2018 14:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526482197; bh=eIugV/ZhIBd7gujY+6Fds4IJU29XoYYFdnjLEEvaoIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAfKRsPGa3GIVrASXMppb3zRTP+bBLLFGHKrtKgbuCzblF5uLIvrQCdf0LV5b+YFV ehZ1zclh1OnTvWBXKSsJOuZDRdzWJUxYfe/ynYzHkDCafuaXI87bMhJBElaZkqk2ct 5jSJ+tL35gmMeBCklY1xRq5Yupm9uEcCth9S5pss= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, YueHaibing , Alexander Shishkin , Namhyung Kim , Peter Zijlstra , netdev@vger.kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 11/11] perf bpf: Fix NULL return handling in bpf__prepare_load() Date: Wed, 16 May 2018 11:49:08 -0300 Message-Id: <20180516144908.22212-12-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180516144908.22212-1-acme@kernel.org> References: <20180516144908.22212-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing bpf_object__open()/bpf_object__open_buffer can return error pointer or NULL, check the return values with IS_ERR_OR_NULL() in bpf__prepare_load and bpf__prepare_load_buffer Signed-off-by: YueHaibing Acked-by: Daniel Borkmann Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: netdev@vger.kernel.org Link: https://lkml.kernel.org/n/tip-psf4xwc09n62al2cb9s33v9h@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index af7ad814b2c3..cee658733e2c 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -66,7 +66,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name) } obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, name); - if (IS_ERR(obj)) { + if (IS_ERR_OR_NULL(obj)) { pr_debug("bpf: failed to load buffer\n"); return ERR_PTR(-EINVAL); } @@ -102,14 +102,14 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source) pr_debug("bpf: successfull builtin compilation\n"); obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename); - if (!IS_ERR(obj) && llvm_param.dump_obj) + if (!IS_ERR_OR_NULL(obj) && llvm_param.dump_obj) llvm__dump_obj(filename, obj_buf, obj_buf_sz); free(obj_buf); } else obj = bpf_object__open(filename); - if (IS_ERR(obj)) { + if (IS_ERR_OR_NULL(obj)) { pr_debug("bpf: failed to load %s\n", filename); return obj; } -- 2.14.3