[lm-sensors] [PATCH] hwmon: Don't leak info in adm1275_probe

Jesper Juhl jj at chaosbits.net
Sat Jul 2 23:18:21 CEST 2011


On Sat, 2 Jul 2011, Guenter Roeck wrote:

> On Sat, Jul 02, 2011 at 04:04:29PM -0400, Jesper Juhl wrote:
> > In drivers/hwmon/adm1275.c:adm1275_probe() we'll leak the memory
> > allocated to 'info' if the call to i2c_smbus_read_byte_data() returns
> > less than zero.
> > 
> > This patch fixes the leak by simply calling kfree(info) when needed.
> > I also considered just moving the 'info' memory allocation below the
> > call to i2c_smbus_read_byte_data(), but I was not sure if it mattered
> > to get the -ENOMEM first in that case or if it would be bad to first
> > have a successful i2c_smbus_read_byte_data() call and then fail the
> > mem alloc, so I stuck with the safe option.
> > 
> > Signed-off-by: Jesper Juhl <jj at chaosbits.net>
> 
> Hi Jesper,
> 
> the fix for this problem is already enqueued as 
> "hwmon: (adm1275) Free allocated memory if probe function fails".
> 
> There is also a second error condition, which occurs if pmbus_do_probe() 
> returns an error.
> 

Ok, cool, then that's taken care of. I'll just drop the patch from my 
personal queue. Thanks.

-- 
Jesper Juhl <jj at chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.




More information about the lm-sensors mailing list