[lm-sensors] [PATCH] drivers/hwmon/ibmaem.c: add missing kfree

Darrick J. Wong djwong at us.ibm.com
Thu Aug 18 20:28:14 CEST 2011


On Thu, Aug 18, 2011 at 07:33:17PM +0200, Jean Delvare wrote:
> On Tue, 9 Aug 2011 11:04:12 -0700, Guenter Roeck wrote:
> > On Tue, 2011-08-09 at 11:10 -0400, Julia Lawall wrote:
> > > From: Julia Lawall <julia at diku.dk>
> > > 
> > > rs_resp is dynamically allocated in this function, so it should be freed
> > > before exiting in every case.  This collects the kfree and the return at
> > > the end of the function.
> > > 
> > > Signed-off-by: Julia Lawall <julia at diku.dk>
> >
> > Good catch. Applied.
> 
> Real bug and good fix, however... This repeated kzalloc seems very bad
> from performance and memory fragmentation perspectives. Given that
> calls to aem_read_sensor() are serialized with &data->lock, it should
> be possible to allocate the buffer once at initialization time and
> always reuse it. I see that the buffer has variable size, but as far as
> I can see the maximum is known in advance (sizeof struct
> aem_read_sensor_resp + 8) so that should be a problem.
> 
> It also seems to me that the error paths in functions
> aem_init_aem1_inst() and aem_init_aem2_inst() are incorrect. I'll send
> two patches for testing and review shortly.

Er... yikes!  Good catch.  I'll try not to be on semi-vacation when your
patches come out. :)

--D
> 
> -- 
> Jean Delvare




More information about the lm-sensors mailing list