From: Borislav Petkov <bp@alien8.de>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andy@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Mike Travis <mike.travis@hpe.com>,
Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Varsha Rao <rvarsha016@gmail.com>,
Nicolai Stange <nstange@suse.de>, Andrew Banman <abanman@hpe.com>,
Colin Ian King <colin.king@canonical.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform: uv: fix missing checks for kcalloc
Date: Mon, 25 Mar 2019 13:55:28 +0100 [thread overview]
Message-ID: <20190325125528.GM12016@zn.tnic> (raw)
In-Reply-To: <20190324225755.1702-1-kjlu@umn.edu>
On Sun, Mar 24, 2019 at 05:57:53PM -0500, Kangjie Lu wrote:
> In case kcalloc fails, the patch return an error to avoid
> potential NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> arch/x86/platform/uv/tlb_uv.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
> index 2c53b0f19329..1ac777f14846 100644
> --- a/arch/x86/platform/uv/tlb_uv.c
> +++ b/arch/x86/platform/uv/tlb_uv.c
> @@ -2140,7 +2140,13 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
> timeout_us = calculate_destination_timeout();
>
> uvhub_descs = kcalloc(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL);
> + if (!uvhub_descs)
> + return 1;
Here...
> uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
> + if (!uvhub_mask) {
> + kfree(uvhub_descs);
> + return 1;
> + }
... and here you can simply do
goto fail;
instead. After having initialized uvhub_descs and uvhub_mask to NULL;
Thx.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2019-03-25 12:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-24 22:57 Kangjie Lu
2019-03-25 12:55 ` Borislav Petkov [this message]
2019-03-25 20:29 ` [PATCH v2] " Kangjie Lu
2019-03-26 16:10 ` [tip:x86/cleanups] x86/platform/uv: Fix missing checks of kcalloc() return values tip-bot for Kangjie Lu
2019-04-23 20:02 ` [PATCH v2] platform: uv: fix missing checks for kcalloc Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190325125528.GM12016@zn.tnic \
--to=bp@alien8.de \
--cc=abanman@hpe.com \
--cc=andy@infradead.org \
--cc=colin.king@canonical.com \
--cc=dvhart@infradead.org \
--cc=gustavo@embeddedor.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.travis@hpe.com \
--cc=mingo@redhat.com \
--cc=nstange@suse.de \
--cc=pakki001@umn.edu \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rvarsha016@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®