Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp528562pxj; Tue, 18 May 2021 08:38:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/UgssL0A8otMKlZZTGccomCODONhc8b5AqdvACyWuG+Ovjnjke9pUKNggwaYBIkE9qRJ1 X-Received: by 2002:a92:d947:: with SMTP id l7mr5105137ilq.266.1621352310277; Tue, 18 May 2021 08:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621352310; cv=none; d=google.com; s=arc-20160816; b=rzNCspA880lMxN8cGj5QcdsdB3pVkuZ6OIsp93iJEKzLnd2OJnDGruldTSEIWKqFbT Un1pAsrWm9coBbYool0/O4b7SjzwNbrDnEQ0yGdrpGhUfw10/XS4Vjggne21eksfR/mu eOv+7f2xURM/ZZgox5y7S0YuCfU+1/Sp0iyP8tp/O9vujdDo+xuMwfLlAvwcXi5UJ8bt 84FiuVA+laA3wB7YuDzrAaNJZ3uMQiIFqpwBIQtoSuQGrY6kXDvWOJjV1GmDtBZWdIyk 2mWYirE9UpeNad02y8sAXf/1/bCowd8biWcEm0D0nfwDtaPGskNsLXKc2/avNm+9i22S XN5w== 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=0/iPVv5DsTvzZt2IpEzzt+sAtQgT6C+DVPSxos7v9h4=; b=pJq4XJEqSiIW40uEb+leY3LfAMjCeJqeeFA2ZpuasacNlqLcaEw4msa0uxYndq7BDs q7p/Q4ezFmGAtAZCS4Z0UmMPW9cLG+PVp5wDeTTEWkDpt+kpFV3H/9JM2mlvD9gCP02B WZWDD+MGw/ydXUcdviBR2bJyiT9SFHsnFFmAw9XBJnwcmk/pS+w284SMTEjWFC+fKAtM BfdBCpFDoOr01evRgk0OkFUHxmHsCv4e/FTHul10RCbv0X3VgYTmCSSJrRBuDpz/Kdr2 YBZl8Hx3J40fl03kQnk4Cj4sIPG8Ms1t+FemyrK1S8xMGmiNVH3fbpT5CMTHqmrlzLWG FPXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H6fQqyeS; 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 j23si19727481ioo.31.2021.05.18.08.38.15; Tue, 18 May 2021 08:38:30 -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=H6fQqyeS; 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 S1345445AbhEQPzv (ORCPT + 99 others); Mon, 17 May 2021 11:55:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:40632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244434AbhEQPg6 (ORCPT ); Mon, 17 May 2021 11:36:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50A6C6193F; Mon, 17 May 2021 14:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262422; bh=NIKtcvpTBbnVYcAxY1CKzGEeqIagAKfxw5hEAm0n5+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H6fQqyeSgDLQMFYNTN+t8g0mf+CYL9+5M2uij4v613BycRQJZxYcLrJJHdJb18phf 5jmE/N57CASFP2jiOsUfPW0tBweT3fwWK4TWiSDx958tTahu4XFb8EXW+786rIVW+0 fU12kGbxrbEzxm5vz8gNk7vtmFsGJOszPBTdEU60= 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.10 184/289] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Mon, 17 May 2021 16:01:49 +0200 Message-Id: <20210517140311.301655056@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 7825adcc5efc..aea9104265f2 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