Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit c831391

Browse files
Conchy-Conchygregkh
authored andcommitted
atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent
[ Upstream commit 51875dad43b44241b46a569493f1e4bfa0386d86 ] atmtcp_remove_persistent() invokes atm_dev_lookup(), which returns a reference of atm_dev with increased refcount or NULL if fails. The refcount leaks issues occur in two error handling paths. If dev_data->persist is zero or PRIV(dev)->vcc isn't NULL, the function returns 0 without decreasing the refcount kept by a local variable, resulting in refcount leaks. Fix the issue by adding atm_dev_put() before returning 0 both when dev_data->persist is zero or PRIV(dev)->vcc isn't NULL. Signed-off-by: Xin Xiong <[email protected]> Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 137e399 commit c831391

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/atm/atmtcp.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,15 @@ static int atmtcp_remove_persistent(int itf)
432432
return -EMEDIUMTYPE;
433433
}
434434
dev_data = PRIV(dev);
435-
if (!dev_data->persist) return 0;
435+
if (!dev_data->persist) {
436+
atm_dev_put(dev);
437+
return 0;
438+
}
436439
dev_data->persist = 0;
437-
if (PRIV(dev)->vcc) return 0;
440+
if (PRIV(dev)->vcc) {
441+
atm_dev_put(dev);
442+
return 0;
443+
}
438444
kfree(dev_data);
439445
atm_dev_put(dev);
440446
atm_dev_deregister(dev);

0 commit comments

Comments
 (0)