Re: [PATCH] atm: idt77252: fix kmemleak when rmmod idt77252

From: Francois Romieu
Date: Sat Mar 18 2023 - 20:31:44 EST


Li Zetao <lizetao1@xxxxxxxxxx> :
> There are memory leaks reported by kmemleak:
[...]
> diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
> index eec0cc2144e0..060f32b0def3 100644
> --- a/drivers/atm/idt77252.c
> +++ b/drivers/atm/idt77252.c
[...]
> @@ -2952,6 +2953,16 @@ open_card_ubr0(struct idt77252_dev *card)
> return 0;
> }
>
> +static void
> +close_card_ubr0(struct idt77252_dev *card)
> +{
> + struct vc_map *vc;
> +
> + vc = card->vcs[0];

Nit:
+ struct vc_map *vc = card->vcs[0];

I have not found any opportunity for a double free related to the patch.

So, other than the nit above:

Reviewed-by: Francois Romieu <romieu@xxxxxxxxxxxxx>

FWIW
- the driver leaks on error in open_card_ubr0.
- some forward declarations (alloc_scq, free_scq, etc.) are useless.
- struct idt77252_dev.next is useless. It was probably cargo-culted from
some driver while hoping to enumerate devices (not that uncommon the
early 2000). PCI driver registeering could thus look more idiomatic.
- deinit_card can be called two times in an error path and trigger a BUG_ON
in atm_dev_deregister.

--
Ueimor