Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp67342pxj; Thu, 20 May 2021 04:44:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGmdLs6ax3G1520lSKDPqbvgaL/V91o6o2W6wHKFvAsPLMKOaIiKMBU8EieePxymGrNDna X-Received: by 2002:a17:906:3411:: with SMTP id c17mr4368047ejb.332.1621511066188; Thu, 20 May 2021 04:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621511066; cv=none; d=google.com; s=arc-20160816; b=020W4FOiVkY/FVTM9Y6mMyAxKZJlqj89k87O90nbXfcUaS9g9Ss8yTI694LJ4atBXr Xk0UzVM0YkAQOQ9SqWhK0bhHqL16qlXezgeBQC3VrRfEkuviTxbM75m6pHr7pnPYX0Mb W+dcBYcHAyVEmEkspyRmC+UM2JLx2Zv26BL8zWC4JGaL1hLUywZWDjwu3EAJ7oxGeOKf H208Bg/aCIb7Wuo6agxo5Jko3kpCDs+teKaA3Pya5xzH+R9gDBP/GFjTdhJ4o0FZadu1 0EtZ5iFRsEb4wKHeh9XkkLLgRDn195ksDwYw7Hpg/5Iy4ytwEroEOkv94w+hD9avjZA3 cmwA== 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=d1LJYRsFmUMzcnsQ9lwJaCMNradkXKJPEudk/YwCOCQ=; b=wiAQeCRZsC71Qz7urQY84XC6ZAbeDtqlDSc9VoNqAQT46coSFP0GLaHhIuNPrV538Y tIxlnfDFA6Wm8gI11e6Ohjj7BNjsoBmH2Bp8cm1djz2gwe5TEKicON9Eg0HxCeUsGSk2 wPSw9UflVP/Ue7+cFMf1D6hgURGVzxGlwW5zsnPn11rQ7FQj59CYymBktzazrHB7pSeK HU1dRG/211hgg5WXi7PPW7YC3ryIVdu+AL/HqYvE3H5bqY/qrai5o4h4WJknzbIM2RH6 H76a3Kuvj3y4R42CDMbMpPndqSF7BMNorEIiw56FK2tkVhK2WyaJ0KIr3fpfm98votFL SxYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uxoc+EEN; 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 q5si2616874ejy.439.2021.05.20.04.43.59; Thu, 20 May 2021 04:44:26 -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=uxoc+EEN; 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 S239689AbhETLmr (ORCPT + 99 others); Thu, 20 May 2021 07:42:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241149AbhETLWJ (ORCPT ); Thu, 20 May 2021 07:22:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 99E50613E6; Thu, 20 May 2021 10:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505494; bh=ucvdEwS9N3zdEKkduSTtwlyI/XRmnJ2wfx/KnKn7nr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uxoc+EENtL237qGRLuncCooVideLHAGN3ArUcLu6Gk3NcRSOrOvcDa5Pmu0FCRUtb Nf6L9H3FShNnJ3/Dg4f3ZxPcvg5ARDGi83sg55+Cc9NDBBSJC8Bj95OKhdg043aPYP AR+FbVGCK0OF37jXqtoftYSlJXUl8CJ41RaMfAWQ= 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.4 161/190] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Thu, 20 May 2021 11:23:45 +0200 Message-Id: <20210520092107.492801926@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 6030efd4a188..1210cd6bcaa6 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -575,8 +575,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