Skip to content

Commit 414f105

Browse files
Conchy-Conchygregkh
authored andcommitted
atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent
[ Upstream commit 51875da ] 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 5414f27 commit 414f105

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/atm/atmtcp.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,15 @@ static int atmtcp_remove_persistent(int itf)
433433
return -EMEDIUMTYPE;
434434
}
435435
dev_data = PRIV(dev);
436-
if (!dev_data->persist) return 0;
436+
if (!dev_data->persist) {
437+
atm_dev_put(dev);
438+
return 0;
439+
}
437440
dev_data->persist = 0;
438-
if (PRIV(dev)->vcc) return 0;
441+
if (PRIV(dev)->vcc) {
442+
atm_dev_put(dev);
443+
return 0;
444+
}
439445
kfree(dev_data);
440446
atm_dev_put(dev);
441447
atm_dev_deregister(dev);

0 commit comments

Comments
 (0)