IB/IWPM: Fix a potential skb leak
authorMark Bloch <markb@mellanox.com>
Fri, 6 May 2016 19:45:24 +0000 (22:45 +0300)
committerDoug Ledford <dledford@redhat.com>
Fri, 13 May 2016 23:40:01 +0000 (19:40 -0400)
In case ibnl_put_msg fails in send_nlmsg_done,
the function returns with -ENOMEM without freeing.

This patch fixes this behavior.

Fixes: 30dc5e63d6a5 ("RDMA/core: Add support for iWARP Port Mapper user space service")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/iwpm_util.c

index 9b2bf2fb2b00674287e74e7cb3048a5fa296b91e..b65e06c560d7ddafa8c53292a5f6e36c917a9244 100644 (file)
@@ -634,6 +634,7 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 nl_client, int iwpm_pid)
        if (!(ibnl_put_msg(skb, &nlh, 0, 0, nl_client,
                           RDMA_NL_IWPM_MAPINFO, NLM_F_MULTI))) {
                pr_warn("%s Unable to put NLMSG_DONE\n", __func__);
+               dev_kfree_skb(skb);
                return -ENOMEM;
        }
        nlh->nlmsg_type = NLMSG_DONE;