OSDN Git Service

firestream: fix memory leaks
authorWenwen Wang <wenwen@cs.uga.edu>
Sat, 25 Jan 2020 14:33:29 +0000 (14:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2020 09:21:51 +0000 (10:21 +0100)
commit787095646bb8f6adde76821477e1bd9368771b71
tree24baa609b4c3e60b0c10941cb040b371a91a90bc
parent6169e11e1f14dd272ec9c746050820e5cc2cf853
firestream: fix memory leaks

[ Upstream commit fa865ba183d61c1ec8cbcab8573159c3b72b89a4 ]

In fs_open(), 'vcc' is allocated through kmalloc() and assigned to
'atm_vcc->dev_data.' In the following execution, if an error occurs, e.g.,
there is no more free channel, an error code EBUSY or ENOMEM will be
returned. However, 'vcc' is not deallocated, leading to memory leaks. Note
that, in normal cases where fs_open() returns 0, 'vcc' will be deallocated
in fs_close(). But, if fs_open() fails, there is no guarantee that
fs_close() will be invoked.

To fix this issue, deallocate 'vcc' before the error code is returned.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/atm/firestream.c