Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp859168pxb; Wed, 6 Apr 2022 02:15:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqvgHHXGVICSHy0nfkz9VhUyc7vj0kKgNRR39SWqyh+AshT1kk6p0297pcmKD7/UvH367M X-Received: by 2002:a17:90a:2a84:b0:1ca:aefa:91b3 with SMTP id j4-20020a17090a2a8400b001caaefa91b3mr9031921pjd.104.1649236506665; Wed, 06 Apr 2022 02:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649236506; cv=none; d=google.com; s=arc-20160816; b=ffV/ox8FFmQnWfOisd0ZxeVsrOqcoPk8X5uo9dXbqakz75GtCuTYDEI0HYBbBaFHnQ VYd4bZ5l+4XTNxNpAn4BU7nvK3Bcjz+E5ozUjnNaegSIKFG00Qysgds6X8j/JCrXdmHg n+FlN/SQ7FxSEmuZbV7wxBOWm4B/Vl9+fxaO5rW3IcT6iWxvf+kKfZ9GGTI+VgzPCmjB 87kW7ykru/qrcBtBssUd3J2+tWY10zAu27qIbtSjVfG4YiQXJXV8I7zlgP3KSVcmfLAz VxM6C4ELsbVihTDt4gte2W0lIEPGb1zKNRBQ3VnahKbMnuE5QG4L6mGdSkuKYeosxdMd ns4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JJ/qtAgV5X7z4aJJR6LiYkpSFe2LIKwSjeSB5T9s1Mo=; b=BS3TmJWMd4hs9powfHigjvrvATL14DPu7qdS0ld4vyMqU9htR/i/Yxi15oloFxPBcf ZwGJYaacDIsh5jV2wtuZ5bl5m6lKvx4mtw22guQdRa6dJO6zoBn2+tyBv/emUQCTiTNm 9SQaBmBiI1p5szNnRhnNfry6JUtpK9DelPXZD+r9CLcjkUNUmTUUg0HPMYfgplfVio5P gw9fvVav6WTT+k6cY4ZWwk5XjwtxrNNm6WMPEyGoDnxU/jmpw8A59C/66Eth5EqRwOg7 UQZmROB9mPTwFh2y06pM4/eKSYPU8kurU2oFU5CJLOHUJEDXo8lGAs7Gh3jLocnoyuR6 sV7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BPzGdoFl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t34-20020a632262000000b0038217a788ccsi15629217pgm.173.2022.04.06.02.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 02:15:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BPzGdoFl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43FBF54E45C; Wed, 6 Apr 2022 01:04:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1847093AbiDFCMx (ORCPT + 99 others); Tue, 5 Apr 2022 22:12:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354178AbiDEKMP (ORCPT ); Tue, 5 Apr 2022 06:12:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9EA3527EF; Tue, 5 Apr 2022 02:58:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 64A186167E; Tue, 5 Apr 2022 09:58:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C16C385A2; Tue, 5 Apr 2022 09:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152682; bh=957SGL9KQznzdENY4XdnryY6MFqclkMVRwcwl8CH+qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPzGdoFltwH3TGxMYYISUNdT1MGvpNTAdn5rkS0aPav1NbM/Q7sFjO7YB0trJpvrm /wbPwzwcsDab8zU1/AMB+7wTvQujVUpvlb+q+KhBgRCuk4lV0QCuUueuZTRs5dPBdq 1EDH6ttxuhVAfZ4bTE9/v2iTsyqo+5ErMHQduQqc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Zeal Robot , Lv Ruyi , "Steven Rostedt (Google)" Subject: [PATCH 5.15 863/913] proc: bootconfig: Add null pointer check Date: Tue, 5 Apr 2022 09:32:05 +0200 Message-Id: <20220405070405.693718564@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Ruyi commit bed5b60bf67ccd8957b8c0558fead30c4a3f5d3f upstream. kzalloc is a memory allocation function which can return NULL when some internal memory errors happen. It is safer to add null pointer check. Link: https://lkml.kernel.org/r/20220329104004.2376879-1-lv.ruyi@zte.com.cn Cc: stable@vger.kernel.org Fixes: c1a3c36017d4 ("proc: bootconfig: Add /proc/bootconfig to show boot config list") Acked-by: Masami Hiramatsu Reported-by: Zeal Robot Signed-off-by: Lv Ruyi Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- fs/proc/bootconfig.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/proc/bootconfig.c +++ b/fs/proc/bootconfig.c @@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_lis int ret = 0; key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL); + if (!key) + return -ENOMEM; xbc_for_each_key_value(leaf, val) { ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);