Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2382673pxb; Tue, 9 Mar 2021 00:41:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoIhXor6yx6rkzN62Uiyg9LF2oiULmrCRLCdGycyUAgZQwK/vrRaSgDuoPfTDT7emLFgkH X-Received: by 2002:a17:907:1b12:: with SMTP id mp18mr19534111ejc.128.1615279292493; Tue, 09 Mar 2021 00:41:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615279292; cv=none; d=google.com; s=arc-20160816; b=CwezH/u8ikMbOc8hPmi/DjXNsUKbwuj05HUfL7Fh6ceIhoZuuD1pRV1nf025IL4auH yeqCtutYrF4ULCCWjXZGYaUuboQNEsg1E/LRdg3FLt8hlQYRU8gS2XXO6crFkVvCwF99 sk++keIHF/tF/ohG7iDLZKDx0kwUXAjM1rMIVzzSxbTRnpSHN/gTO3hu9GA+fpDKxJif zuOlEG4J0cQU7FsISdrYn86awPy4naxo9qCc+VrM1J3ZORYkVVgIATyv46U3yUCITdSI q6zy/jPcorduHapuYPFAdPDL3NUKBeC6WNvy/tWh5ZrSPT8isjyMoZJw1Lxylp7Xvs4q ytsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=+5eeJcJYQlUo+55ExUdi0rlAWB1hTePo43XNL4GdBGo=; b=i1gpulzJ3w/4P3zEwYZ78F9yWh23KnRtMoRGrhhOrIdtsFdYn/SDAg0QxBVEhi7F8f mwnQUdXvrblBHi/5es6qvIoZEfVFikXc/qq19QceGt/G9K4DIfU6sb+xQajq5VgvKNFO v9kRiv9Q3WjhmsVMI5Iizsiu7F+KUwpdp5J7uCNE7nO6vht01b7G3OJg92wSdkyJpAHW wEJQZ0EMTPvtFG1Uy+8f+qQE2RgqM3VSiVSnmas3XJU6tmKH5G4EdgJlqOKQdbA/qJJj UZFcMD/PeOotuEJH719Wyjoc1w0b5XpDQV5fUTlPTBgG0Oj2FXEihCZdgDi5nGDDqZip S2IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jcUDw2dN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi22si8712795edb.191.2021.03.09.00.41.09; Tue, 09 Mar 2021 00:41:32 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=jcUDw2dN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhCIIjj (ORCPT + 99 others); Tue, 9 Mar 2021 03:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbhCIIjM (ORCPT ); Tue, 9 Mar 2021 03:39:12 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F19AC06174A for ; Tue, 9 Mar 2021 00:39:12 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso4786732pjb.3 for ; Tue, 09 Mar 2021 00:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+5eeJcJYQlUo+55ExUdi0rlAWB1hTePo43XNL4GdBGo=; b=jcUDw2dNH4Cqg1cZUwJU3k3LIhqUIXqBdPGMLcvtSh6vS2nNoxsVMGzwRIYOXWhCem 0kxdVXgPBndsbydFBNWCK8yp9AN8DrT9Zk+4mWTvMwbPVUawxxNT7ayGhxiMxATJHQOW aKW83aOnbV7i/+TZwU7eEinK8OP98Xo7sr2LUQYWVvW+Q+0QEGhb4U/Aj+Q5cwkbyXgR ExN0SSxYm3lvI/Yocpxywa8fjNPdXwI3QqfdOqYzJ0yKaSJFrwUHhEuA/miemm5j02ep 6K9ej47KB2ZV4hjLQtpI6pJQCInQfAvBDFw3rBYrekpu6RvbVbiBJsVCrA58qILFr1/L MueQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+5eeJcJYQlUo+55ExUdi0rlAWB1hTePo43XNL4GdBGo=; b=QENPQKGtvapQVtcm2YWLCtKO1F1driEYzvwxxgwc8w8uV6KHRgTTnIVkBqMdftqOtf 5Pf5ZLvnng9RMXrGOczGeFlNXpBThM0qdvEi/dyA78ZOiOKYPMvtdDZ7IX5ynZ5frP5C xtOzPfc4kTLxzx+aPY8CjAJSzFApfNyidnNu3QJjDKnxHb01+nh4WI3XiOAmRs0qwW0V cc2RRmtZ9ujfCKGdfNJobp6zOFOKMXDWAlvbGeYY7vstwiram8faL2YgpafMlCkxeyLB LARQS4YiHt8yqa1fshGPA1MFDOgrhYaXUZpbVfblIXzp6EERrr7TsARYl6OIfsla0fAl Zkkw== X-Gm-Message-State: AOAM533T8pAcCFSPAKQpL9KtpHN/zhFSRk0nSie5G3961vvxAy77u9DD jY2Tx+z8he3i4pGGUxh66+k= X-Received: by 2002:a17:90a:7884:: with SMTP id x4mr3434850pjk.185.1615279151986; Tue, 09 Mar 2021 00:39:11 -0800 (PST) Received: from localhost.localdomain ([45.135.186.97]) by smtp.gmail.com with ESMTPSA id p17sm1964512pjv.49.2021.03.09.00.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 00:39:11 -0800 (PST) From: Jia-Ju Bai To: ebiederm@xmission.com Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Date: Tue, 9 Mar 2021 00:39:04 -0800 Message-Id: <20210309083904.24321-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: a43cac0d9dc2 ("kexec: split kexec_file syscall code to kexec_file.c") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai --- 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.17.1