Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp382287pxj; Thu, 20 May 2021 11:30:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxUAoUTWXEtGsplDfgHej/gFJIw3XjLXxEWWlAvIZH+u9eeb07rf0KaNcDH+fWMDwNzcBe X-Received: by 2002:a17:906:1701:: with SMTP id c1mr6012098eje.425.1621535413091; Thu, 20 May 2021 11:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621535413; cv=none; d=google.com; s=arc-20160816; b=B7aJrAhM9N6VIDXMnPyz/GiPxp+tvuv8Rw8Nx3xeeNfqQDBW4LRHdybhoXWYhhie3J zDlH9IGwwKYrPS/4vmVqX3ewFUkk2+lc8+Rop+cx8MyGq+ww7Wb5iQi+dohQ3w58qe41 UrvitbJqrk/UaAF/GPddTcsyERHzdBIN4s9t1ns41IrX6NKAVDplPUiPEoLGdBdpqrl/ h9KoWct3UEMGHVzNSc0ijojVHdQ9xIYLETYaM4Eo5YNlwdoTukHQtnNKI/0zoxDuuf7a kjg2o/3wydkrkvLCMwtkJsCIShmAWwfh1FPbebr+5hmyPY8+gZAO9k9sI9LAr5xRp/Eu l/mg== 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=tdqnYrWaeR2EiYYRqKpK/Ze0nbGG81OOx6Mu9i2V5Ho=; b=y3gcvF59VPNg+9xW+ocZcgQVtKtQ3i0vaSYp14RP+TijpyR0Bc7wYzIWpQq3LJH4iz Mwy8I8KwFUX7aARVpJaIbOGSH7XbbNgdryvmh+qb69Nge01/UkxLr1IMdOns8y/aPIcq amhq02trfPN6JMeRAh+0dY1toUoAD7K8BRpqnnlChUq53Mw56hWS4fWlxI7TSGV/Fzod XPuekv9fzTXD7+II04uk124Qc/KQ+4hkefOJFxKLDw54ByYv7TnKbU+Bpm2Ki/Ute2/8 IsHZJspLJA6yn2QdkukfddzHJUf7T/Hf0wJxOoetYu+fkyhco7y6KGhfWk8KFAODZSW3 XKKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eWs9CbFz; 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 k9si3256922edv.206.2021.05.20.11.29.49; Thu, 20 May 2021 11:30:13 -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=eWs9CbFz; 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 S236199AbhETKSE (ORCPT + 99 others); Thu, 20 May 2021 06:18:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:42256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235818AbhETKJ0 (ORCPT ); Thu, 20 May 2021 06:09:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 878E26143F; Thu, 20 May 2021 09:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503745; bh=ENKjntE/hqgGiVtup0wTNSNXB55unZfSsC6FHVrNWAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eWs9CbFzrp7sXCGOnJfQuh3VOg3ii/LvG3sSZFiY4iXVsMy+1k76jt5i462JXX34q ddBjlFp6LHxvMUspDvlqXIp8IF/ss90AqnIblh15VG36lQiJ74zj/Ypk4Vb8BSGb3i iUqQNoJB8pL+HMa5an/TyZNybdePvbncp153tiTQ= 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 4.19 359/425] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Thu, 20 May 2021 11:22:08 +0200 Message-Id: <20210520092143.202712878@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 2fbdb78d66c8..89d41c0a10f1 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -631,8 +631,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; desc->flags = 0; -- 2.30.2