lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 21 Jun 2010 08:34:18 -0700
From:	Jesse Barnes <jbarnes@...tuousgeek.org>
To:	Jiri Slaby <jirislaby@...il.com>
Cc:	Jiri Slaby <jslaby@...e.cz>, mjg@...hat.com,
	platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] X86: intel_ips, check for kzalloc properly

On Mon, 21 Jun 2010 17:33:48 +0200
Jiri Slaby <jirislaby@...il.com> wrote:

> On 06/21/2010 05:25 PM, Jesse Barnes wrote:
> > On Mon, 21 Jun 2010 17:02:11 +0200
> > Jiri Slaby <jslaby@...e.cz> wrote:
> > 
> >> Stanse found that there are two NULL checks missing in ips_monitor. So
> >> check their value too and bail out appropriately if the allocation
> >> failed.
> >>
> >> Signed-off-by: Jiri Slaby <jslaby@...e.cz>
> >> Cc: Jesse Barnes <jbarnes@...tuousgeek.org>
> >> Cc: Matthew Garrett <mjg@...hat.com>
> >> ---
> >>  drivers/platform/x86/intel_ips.c |    3 ++-
> >>  1 files changed, 2 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
> >> index cdaf40e..3c7ea9a 100644
> >> --- a/drivers/platform/x86/intel_ips.c
> >> +++ b/drivers/platform/x86/intel_ips.c
> >> @@ -931,7 +931,8 @@ static int ips_monitor(void *data)
> >>  	mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
> >>  	cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
> >>  	mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
> >> -	if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples) {
> >> +	if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples ||
> >> +			!cpu_samples || !mchp_samples) {
> >>  		dev_err(&ips->dev->dev,
> >>  			"failed to allocate sample array, ips disabled\n");
> >>  		kfree(mcp_samples);
> > 
> > Ah cool, am I also missing the appropriate kfree() calls for the last
> > two?  The context doesn't have it.  Otherwise,
> 
> I checked when I was patching that and the last is not freed there.
> However I didn't add it since at least one must be non-NULL and in this
> case it can be only the last. (Until somebody add another allocation
> indeed.) So should I add even the last free there?

Up to Matthew.  Not adding it will make people do a double take, but I
agree it'll be safe.

-- 
Jesse Barnes, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ