Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp634834pxb; Tue, 5 Apr 2022 16:44:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtee0Ta+/aDnXr2DmSgb8MUOYYyG/rOeXSimsheERIDksBz15u2Crh9m7b/P7G7syv8wbR X-Received: by 2002:a17:902:da91:b0:153:cc84:f13f with SMTP id j17-20020a170902da9100b00153cc84f13fmr5864869plx.38.1649202271580; Tue, 05 Apr 2022 16:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202271; cv=none; d=google.com; s=arc-20160816; b=JeLEouwqSYJEakRa4zQfX1I6VfG6YW29HrwZNXL1f7OquoXTQ7A2gQQ0NAVz+2F5cF rrcJXv8rgllUYSi5JiwnGnRE3gx+3XMoo/moUTwHAODxY6NrqSDbw+R+Sovm/WMWsIQi nNdS6TRRiR0ZCsIb2iFzCKa9KKy18a3KAy64TYZJXTrL/aKkUogZiUKJTT9zS2cv0ATt cdmgqNHVYzsT/zCuz67xZl3lJPhCXUL3dpqGlv2tmp7epPeNtM4z/kDcsJvQ9GzoExcu sgmkaKmaAIY1b3E7bsO7lj/cebCHMykZuA3Wt4vRtiEqfZdleQT1gVirYBjWp6rAxnAW B73Q== 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=By+dceyMzWb58dKI2u0fONrrotPQKBqzHJVrfudse/Aotnk75YjxLqaW4GXSohklfR A9Bk0mqK6dcn45T1EpyzkTrqe0ubBNXY0nikx+4GL5kTJSd/NkypWumwvBZO+9wJ8UAR BR8PQs5ckBm7fboF8XslN9LMoKK/edliheP40P2dPwnsRnYAvVfsevmZ+FqP228kFviv phL+sVu7A6TMzVxHNl3EeCTzhrIpIddQUA9hBK+/R97fb1FNYh11UJAwIQh7c4mfO2aW 8eAdRiuSA73D7oWfNxbf48Rb7wKSbNwBbo0mYquhdlxpzSuv6jPAhBXz1JfL1lnyZsw9 FyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2phdhIIT; 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 i12-20020a170902c94c00b00156b46b4cabsi6672721pla.228.2022.04.05.16.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:44:31 -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=2phdhIIT; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50DAB25D5F5; Tue, 5 Apr 2022 16:30:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350683AbiDEOBc (ORCPT + 99 others); Tue, 5 Apr 2022 10:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348017AbiDEJ3E (ORCPT ); Tue, 5 Apr 2022 05:29:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C10DE0981; Tue, 5 Apr 2022 02:16:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8D7C3B818F3; Tue, 5 Apr 2022 09:16:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0476EC385A0; Tue, 5 Apr 2022 09:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150164; bh=957SGL9KQznzdENY4XdnryY6MFqclkMVRwcwl8CH+qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2phdhIITogJ0hrOUyoTyJIL0k+MnCyxfCLdled4Xy/lqqrU1O0clzr9nzu2ge4C6x gcdmAnVLTsf4ceFrr6Q+jglIU0mnJaIx729vr4P26IqUpiSe6X7KAIIGoeFSlut37f aNEB+2SOOQFMEULYeXCk1DJMPiwA3jruWCcd2PMo= 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.16 0960/1017] proc: bootconfig: Add null pointer check Date: Tue, 5 Apr 2022 09:31:13 +0200 Message-Id: <20220405070422.704281964@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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);