Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3114222pxj; Mon, 17 May 2021 18:08:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnG3YH54hn4eF7CoLIr8gn5OQO1siNn7ou05eSbplPxQnvUP+E9sW2LtLtV1SvxKeUoIco X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr3800600edv.356.1621300101596; Mon, 17 May 2021 18:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621300101; cv=none; d=google.com; s=arc-20160816; b=ODmSCsgBug5/lqoKZue1ShQAomU9z5EKxbuUKoNax6qoZU9d4HNiuXCEht1MZ7Y0pA aQLxj8ptZ0kzwwcSeS7d4zdb4/YkAWAmBD3QNhcqq37T5o7p5SCitHlfUA3uBkRXoR5x 7+XcONar+Rs3PvTbs1dyjXEIPVWRwfJWpDQ7W2CG1aBZFL6hOgNWRHN+mWM62hkA2RfL 39eWF/GliQgweI6x5XF6jbni+QF6w5xfzEIkGu9AWHm+/JeBDiPApSv8yfO5btTyKEIj SpUFwuHa8i2KK5jFQP0Nr02yV6yQFk5cq0KiJOZcE+a4zoOUxLZSu8qSVDAAOXvZnT6V jRRA== 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=Eqhq1lFu/kw1KsiIL7imYooA0hOnlFCsjTb5D5xMp40=; b=HZC1Ya6bg6scu2PHN11E/pQC+swQZQvwB66BLYQU4rgBCbaYycerkbzd5s44HxJfQu e0t0JYP40sIGHi7tl+G15KfsprPyu06Vn79DuBYjXy3eccSKaT4l61kgSPvnbnlEurSu TC2CLFOqj56pBtiPQedc5/iRb+wt/qw+Q1oiQXeDe1MskGp902zvzw+o7HZEj0AzANfY JV5rEA33czrdYZrhe1PvZwbu/fxpcfVulyQ33nDP9/CvMm+B+47YXSmU/EhKiCapO7j6 rGR4+UsHtyrsMO/4qicduj5SLQVXBMz3sCOkdTKrN137G9JYhPLuOqI8wE6TdwfCuNlj PEoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="y4S3he/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si15751848ejc.334.2021.05.17.18.07.58; Mon, 17 May 2021 18:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="y4S3he/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S238620AbhEQOaP (ORCPT + 99 others); Mon, 17 May 2021 10:30:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237832AbhEQO0I (ORCPT ); Mon, 17 May 2021 10:26:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FFA061493; Mon, 17 May 2021 14:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260797; bh=XfB93B0iqSXfeJP3MGmy9gtOaMXAym7u33cGOrQejFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y4S3he/gBWGUwvH+1E0alzOkL6775QRYa5l7bDhCJ9UznZU6Du6tbMcI/lZWNWyXY B6CNKV35zFoA6xgrMeIYvPylaQX69zpDMdpVWjrrR7QXyGD6AS5paT6jwJJfScFlVh GtRBr6630KEub6QTkUvSLdijOMCtKrFGUzBhUjow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , TOTE Robot , Baoquan He , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.12 238/363] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Mon, 17 May 2021 16:01:44 +0200 Message-Id: <20210517140310.634696732@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 31d82c2c787d5cf65fedd35ebbc0c1bd95c1a679 ] When vzalloc() returns NULL to sha_regions, no error return code of kexec_calculate_store_digests() is assigned. To fix this bug, ret is assigned with -ENOMEM in this case. Link: https://lkml.kernel.org/r/20210309083904.24321-1-baijiaju1990@gmail.com Fixes: a43cac0d9dc2 ("kexec: split kexec_file syscall code to kexec_file.c") Signed-off-by: Jia-Ju Bai Reported-by: TOTE Robot Acked-by: Baoquan He Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 5c3447cf7ad5..33400ff051a8 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -740,8 +740,10 @@ static int kexec_calculate_store_digests(struct kimage *image) sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region); sha_regions = vzalloc(sha_region_sz); - if (!sha_regions) + if (!sha_regions) { + ret = -ENOMEM; goto out_free_desc; + } desc->tfm = tfm; -- 2.30.2