Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3977352pxb; Tue, 25 Jan 2022 00:28:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVHklmKY0JzmtaFr1j50X3KI08/enMFj8HDSUCJU3+aWpdGmmYr3YNCxo1y5KrgNmIeq+Z X-Received: by 2002:a17:906:69c8:: with SMTP id g8mr15018141ejs.356.1643099308750; Tue, 25 Jan 2022 00:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099308; cv=none; d=google.com; s=arc-20160816; b=LKgjSr2ws5aEqTb+XFhXvLT03POKwxlRtsgRyyBsW1uqA9FGUZ2+aiabJaF3zrT6xL 61ZQuB6XrHhzC/UH0QmrdSAJtqJjjxuMVSiGpTLJDWVUBzIUsiYJS+sIFxNmDH8JB1zW tfrceUZfToln3DuOWVQHrgSxsfnYTZGeKlLhP4sb+pH9vlibufeef93PEY99DazA6xPH svUzt6tMplJAFMZpH/bMRSu0ErRrjo6xCm3GgY6Dd2udXAlvPOwy/LJxU1tele8NBHlK 0iUY55tBmxWgsmIocG+l/d51L5ldvwmKXte6QM7zN4Axa02LEkVMD0Q5CLny58HHic1T DjAg== 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=xu1rOXpiUrlw3gkot/nBRaeoIadpW1kfCGm6lS6+rg8=; b=qC3MbcIdPQfKQTXgjpvJzq5UJc19X0ZYNn+TGSsqzlGOsn5V5ymUlsj6gl9/jPORI8 BRZNG5dz+Oqcaq6fSpGO9zRZ7Fc2ACkx+Rj4IH3KYUnfaapHEK3FeR1tWGeXsslthOz7 tu7Ai8adZBbH8LbWqlTbcLj1C07mVbuy3qZ0htLGOqTnasZbsxnAfD6sRuwpra+h1C3g NVIIgFx+5fs+XMgxX90wZ/rxOMVCiRjSnwryfDynssHjt7mW8y1tsSMUaDAQQ5BXmMa/ Fm8i5K6+Te95gzo7frSy4ASW3i1PW0lhFuMo/cu6UCQebVDdncMDupKSAtgsD9GqUYXJ SMLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2pYqU4Gb; 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 i6si10222748ejw.591.2022.01.25.00.28.03; Tue, 25 Jan 2022 00:28:28 -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=@linuxfoundation.org header.s=korg header.b=2pYqU4Gb; 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 S3423241AbiAYCdV (ORCPT + 99 others); Mon, 24 Jan 2022 21:33:21 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:52350 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383330AbiAXU1J (ORCPT ); Mon, 24 Jan 2022 15:27:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6557F614EC; Mon, 24 Jan 2022 20:27:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 492A8C340E5; Mon, 24 Jan 2022 20:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056028; bh=3bYJ1Uv45V46z7TGSRB+5GaY5VET5wRoQDd1kBkBs3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2pYqU4GbYQCklm0JVshHrPvdC5ObQnmilOZhsFt8+n8xp8mNvil8EQyw1R6uNLj4s wrVyxXZU5OkTQhwUjTphcMstpX/4FytIRrIGXKo8hvPfXxkNnx0amdLE7sFL5NopD/ qiMAZGnuccxmHHC9GEYMWj940aZw5391r3RaeRAg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zizhuang Deng , Tianjia Zhang , Herbert Xu , Sasha Levin Subject: [PATCH 5.15 346/846] lib/mpi: Add the return value check of kcalloc() Date: Mon, 24 Jan 2022 19:37:43 +0100 Message-Id: <20220124184112.880158506@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Zizhuang Deng [ Upstream commit dd827abe296fe4249b2f8c9b95f72f814ea8348c ] Add the return value check of kcalloc() to avoid potential NULL ptr dereference. Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library") Signed-off-by: Zizhuang Deng Reviewed-by: Tianjia Zhang Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- lib/mpi/mpi-mod.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mpi/mpi-mod.c b/lib/mpi/mpi-mod.c index 47bc59edd4ff9..54fcc01564d9d 100644 --- a/lib/mpi/mpi-mod.c +++ b/lib/mpi/mpi-mod.c @@ -40,6 +40,8 @@ mpi_barrett_t mpi_barrett_init(MPI m, int copy) mpi_normalize(m); ctx = kcalloc(1, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return NULL; if (copy) { ctx->m = mpi_copy(m); -- 2.34.1