Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2121227lkv; Thu, 20 May 2021 03:55:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuR8KixaGlCqT0GNm5qzV/0UwmyvnGqxtmBrU/w3v+U/42fdPhFflLt6xilxAMKdcTndTZ X-Received: by 2002:a50:a446:: with SMTP id v6mr4368474edb.254.1621508123411; Thu, 20 May 2021 03:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621508123; cv=none; d=google.com; s=arc-20160816; b=KXp1Ap3xBR3i0uL/VRNWE3+5e+lUQW69uUwgg1Uz0uVE5CgbZMK4Ue/HzzBxN3Nj1w nSQXQBEO3q9rucAE1rARx1dQJmV4OH0pV+mKOhB8s8nvvIfXYQfc8nS8nSCxNfAkxDWZ KkVZn6wKhUVNBaYgG3uWMPv69J3YEWnKI8ELg4Ifr+Oi6/MR+oT3GAYdzaK3Ac50ZEfA 9MAFdanZNBYGUeDxJlcXDpEY2M9mrKvZHzBtLT6YwEmc1hidHRAknAiDEbHQyxoAw8uz YTSeU9Kwsenj9fr4F3nwlJQH9SUTxIctyNkU1GgLYZ+4svEwYcIBzAERVKIAHB0Oc6ik WPxg== 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=Dx/3Vi8q+2O9kSY9q0cJWnVt1HopTg9pvvXv7CkfybA=; b=oMZs8WzRdWIy9JbIEDrjIx+q9yv+2P0HhElJweHetSxHGBMnZLdblFPEqpheEGqXY0 3DcBfqJyYLm1SFlGY87GbeOC/QG120R1O9Wxg7J2xIZpg/ecJV4ktpiTEV9/msmhcCJb 6SHKkfi1B3Tq92xefHd17kUyvJxerksF6V0co4stFITfC3CnkBU2q6JTQdBZJxM5JdhC D8yIVK3995O/iDe8Cev0Ysmu1U0GkrQr1QKDzSvEZlOJkjEyg8+0yBrLlIW7Sw2mSADg L8CaL26WzWbAH8+7KacOCR1egu1Q35J6Ha/OBDqFSqCwY9iJjFdiBnoGqIEsp6l2R3/g F/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vNuoTQMq; 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 gt38si1956725ejc.742.2021.05.20.03.54.59; Thu, 20 May 2021 03:55:23 -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=vNuoTQMq; 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 S238868AbhETKyP (ORCPT + 99 others); Thu, 20 May 2021 06:54:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237582AbhETKiq (ORCPT ); Thu, 20 May 2021 06:38:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5285161C80; Thu, 20 May 2021 09:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504503; bh=N3li9ai6utV9UDBE2Qj4IlEAa2YDmLknKwoj1NHvmjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vNuoTQMqfcpLAyL2YYDe9JsmhIYkixhrvqXIcvBHzosagcsuOCoK9bvvjNUG5PbrC f/Pv5y/1mqKpZV/JYPNdXmf/to7s9Ze2Ps5n16kcnm8vOLXU53arx5PEKtQ3wvSF8r vtbRSu8+mNX6++h3bIdx2BBocj6V9kfQzqtrtMPs= 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.14 274/323] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Thu, 20 May 2021 11:22:46 +0200 Message-Id: <20210520092129.612326763@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 6d0bdedb2e20..9d979b2954ef 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -554,8 +554,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