ata: pata_parport: fix memory leaks
When ida_alloc() fails, "pi" is not freed although the misleading comment says otherwise. Move the ida_alloc() call up so we really don't have to free "pi" in case of ida_alloc() failure. Also move ida_free() call from pi_remove_one() to pata_parport_dev_release(). It was dereferencing already freed dev pointer. Testing revealed leak even in non-failure case which was tracked down to missing put_device() call after bus_find_device_by_name(). As a result, pata_parport_dev_release() was never called. Reported-by: Nkernel test robot <lkp@intel.com> Reported-by: NDan Carpenter <error27@gmail.com> Link: https://lore.kernel.org/r/202303111822.IHNchbkp-lkp@intel.com/Signed-off-by: NOndrej Zary <linux@zary.sk> Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
Showing
想要评论请 注册 或 登录