Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp670242pxb; Tue, 5 Apr 2022 18:06:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL6sYP6shxt1wiB6mE0qQt2OmVPjmNR6yr9IhICckCKe+1SW9I4ezn3KeH9gMORpN7bIVW X-Received: by 2002:a05:6402:2688:b0:419:5dde:4700 with SMTP id w8-20020a056402268800b004195dde4700mr6425740edd.124.1649207180565; Tue, 05 Apr 2022 18:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207180; cv=none; d=google.com; s=arc-20160816; b=ga/RJFsNL1D0/XjyrgkodiuihlgCKWp8sPAdIpawyq85E+1q34qPEnrFwE8gcD1Tn2 BL4vF7WzCuNdFNWr27+Y0a4nC02nnXdDU9um8v/Vteb3l89MV4sERdyU3EFf5iOUcvW2 lrTtsRsw9mW6eP0UTyGJ3JF/e3f7qu4fVODRiLi0GvMHPjZGH95e1znxvmngKXVlP0Go naT18FeK1gWtB+7/6gcEV2CfX9Yo+wBLiESJHsygOrHiPYBMjYSsEhNPpe1jim0kffir lEe13Bnq7vExv4Bl//Y5IQ0TDVTWSpu+8A8eBcgqpH6coSHH7oGoL2FeEMTZLCv9EX5o 3pUw== 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=SaTKev9ymQ4oeEDYdgoVm2/jvWHRGrMvv/5YcL3lgjMrbsqBK8O1r157U3iLtB8wXN iH6XFE3FdBh1kQ2dvay+iBCxkA8OSgztICf5k/JTluVOFyd3YuvSKr0D9P8jVYvpP83Q rDJpnoS0hP+pig7NXfZ97ImWQnidfXl7YbYDBYOveUCNiKsmHlB07lln2ToQ1B7oihcn 7ONUgVaa5CVa6eg3B5sDopqg5AC8wpEV7nH/u+p8VgIN5Or5+PSBxvRAFVm0okgFZoNo Qd6Ri2Njgx/HOa1Z3PeZ4FdSixiWtM5ocijW7HpYo3gbJcXhzBlMfOR4NvXaeMJHrjVG VjEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EpQGnyXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz5-20020a170906bb0500b006e6c486794bsi7847035ejb.485.2022.04.05.18.05.55; Tue, 05 Apr 2022 18:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EpQGnyXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357701AbiDEK05 (ORCPT + 99 others); Tue, 5 Apr 2022 06:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241116AbiDEIcv (ORCPT ); Tue, 5 Apr 2022 04:32:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D13BC08; Tue, 5 Apr 2022 01:27:52 -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 7E3C560AFB; Tue, 5 Apr 2022 08:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B539C385A2; Tue, 5 Apr 2022 08:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147271; bh=957SGL9KQznzdENY4XdnryY6MFqclkMVRwcwl8CH+qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpQGnyXgqyjfLkxRWC7OxPM8Fn99PXXf3sLId6xk7S/qwYkV/14GGVZZXugZUVmJE DWdHiuwGAxKQk5H3Z4CGRiN/JnY4zKeNCpkjbZ288vb/uMqorz/vE7esM1a4kup+0+ yYiWK/fHgD1z6YYa3SKySr1u2eiGw/oimJbw/YqA= 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.17 1064/1126] proc: bootconfig: Add null pointer check Date: Tue, 5 Apr 2022 09:30:11 +0200 Message-Id: <20220405070438.689996007@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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);