Skip to content

Commit 44f8baa

Browse files
HBh25Ydavem330
authored andcommitted
net: sched: fix possible refcount leak in tc_chain_tmplt_add()
try_module_get will be called in tcf_proto_lookup_ops. So module_put needs to be called to drop the refcount if ops don't implement the required function. Fixes: 9f407f1 ("net: sched: introduce chain templates") Signed-off-by: Hangyu Hua <[email protected]> Reviewed-by: Larysa Zaremba <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 682881e commit 44f8baa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/sched/cls_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,7 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net,
29502950
return PTR_ERR(ops);
29512951
if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) {
29522952
NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier");
2953+
module_put(ops->owner);
29532954
return -EOPNOTSUPP;
29542955
}
29552956

0 commit comments

Comments
 (0)