From nobody Tue Jun 16 01:39:13 2026 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 9DDD2C433F5 for ; Thu, 21 Apr 2022 13:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbiDUNDv (ORCPT ); Thu, 21 Apr 2022 09:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbiDUNDt (ORCPT ); Thu, 21 Apr 2022 09:03:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DFE6327; Thu, 21 Apr 2022 06:00:59 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Kkd272qRRzhY2n; Thu, 21 Apr 2022 21:00:47 +0800 (CST) Received: from dggphis33418.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 21 Apr 2022 21:00:56 +0800 From: Gaosheng Cui To: , , , , , , , , CC: , , , , Subject: [PATCH -next] libbpf: Add additional null-pointer checking in make_parent_dir Date: Thu, 21 Apr 2022 21:00:56 +0800 Message-ID: <20220421130056.2510372-1-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The make_parent_dir is called without null-pointer checking for path, such as bpf_link__pin. To ensure there is no null-pointer dereference in make_parent_dir, so make_parent_dir requires additional null-pointer checking for path. Signed-off-by: Gaosheng Cui --- tools/lib/bpf/libbpf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index b53e51884f9e..5786e6184bf5 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -7634,6 +7634,9 @@ static int make_parent_dir(const char *path) char *dname, *dir; int err =3D 0; =20 + if (path =3D=3D NULL) + return -EINVAL; + dname =3D strdup(path); if (dname =3D=3D NULL) return -ENOMEM; --=20 2.25.1