net: rtnetlink: fix module reference count leak issue in rtnetlink_rcv_msg
authorZhengchao Shao <shaozhengchao@huawei.com>
Mon, 15 Aug 2022 02:46:29 +0000 (10:46 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 16 Aug 2022 02:58:30 +0000 (19:58 -0700)
When bulk delete command is received in the rtnetlink_rcv_msg function,
if bulk delete is not supported, module_put is not called to release
the reference counting. As a result, module reference count is leaked.

Fixes: a6cec0bcd342 ("net: rtnetlink: add bulk delete support flag")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20220815024629.240367-1-shaozhengchao@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/rtnetlink.c

index ac45328607f77af33cf51f85f9918376a9fe8ae0..4b5b15c684ed63522325740dea0678a71cd07206 100644 (file)
@@ -6070,6 +6070,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
        if (kind == RTNL_KIND_DEL && (nlh->nlmsg_flags & NLM_F_BULK) &&
            !(flags & RTNL_FLAG_BULK_DEL_SUPPORTED)) {
                NL_SET_ERR_MSG(extack, "Bulk delete is not supported");
+               module_put(owner);
                goto err_unlock;
        }