Skip to content

Commit dd4edbc

Browse files
lxingregkh
authored andcommitted
dccp: fix a memleak for dccp_feat_init err process
[ Upstream commit e90ce2fc27cad7e7b1e72b9e66201a7a4c124c2b ] In dccp_feat_init, when ccid_get_builtin_ccids failsto alloc memory for rx.val, it should free tx.val before returning an error. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent adcc878 commit dd4edbc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

net/dccp/feat.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,9 +1471,12 @@ int dccp_feat_init(struct sock *sk)
14711471
* singleton values (which always leads to failure).
14721472
* These settings can still (later) be overridden via sockopts.
14731473
*/
1474-
if (ccid_get_builtin_ccids(&tx.val, &tx.len) ||
1475-
ccid_get_builtin_ccids(&rx.val, &rx.len))
1474+
if (ccid_get_builtin_ccids(&tx.val, &tx.len))
14761475
return -ENOBUFS;
1476+
if (ccid_get_builtin_ccids(&rx.val, &rx.len)) {
1477+
kfree(tx.val);
1478+
return -ENOBUFS;
1479+
}
14771480

14781481
if (!dccp_feat_prefer(sysctl_dccp_tx_ccid, tx.val, tx.len) ||
14791482
!dccp_feat_prefer(sysctl_dccp_rx_ccid, rx.val, rx.len))

0 commit comments

Comments
 (0)