Skip to content

Commit fea1298

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 <xiongx18@fudan.edu.cn> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0adedbf commit fea1298

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
@@ -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)