Re: [PATCH] fpga: Fix memory leak for fpga_region_test_class_find()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 09, 2023 at 02:03:18PM +0200, Marco Pagani wrote:
> 
> 
> On 2023-10-07 11:43, Jinjie Ruan wrote:
> > When CONFIG_FPGA_KUNIT_TESTS=m and making CONFIG_DEBUG_KMEMLEAK=y
> > and CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN=y, modprobe fpga-region-test and then
> > rmmod fpga-region-test, the below memory leak is detected.
> > 
> > fpga_region_class_find() in fpga_region_test_class_find() will call
> > get_device() if the data is matched, which will increment refcount for
> > dev->kobj, so it should call put_device() to decrement refcount for
> > dev->kobj to free the region, because fpga_region_unregister() will call
> > fpga_region_dev_release() only when the refcount for dev->kobj is zero
> > but fpga_region_test_init() call device_register() in
> > fpga_region_register_full(), which also increment refcount.
> > 
> > So call put_device() after calling fpga_region_class_find() in
> > fpga_region_test_class_find(). After applying this patch, the following
> 
> Looks good to me. Thanks.
> 
> Reviewed-by: Marco Pagani <marpagan@xxxxxxxxxx>

Acked-by: Xu Yilun <yilun.xu@xxxxxxxxx>

Applied.



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux