diff mbox

[rdma-next,1/4] IB/iwpm: Fix a potential skb leak

Message ID 1462340165-16067-2-git-send-email-leon@kernel.org (mailing list archive)
State Superseded
Headers show

Commit Message

Leon Romanovsky May 4, 2016, 5:36 a.m. UTC
From: Mark Bloch <markb@mellanox.com>

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>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
 drivers/infiniband/core/iwpm_util.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steve Wise May 4, 2016, 3:36 p.m. UTC | #1
> -----Original Message-----
> From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> owner@vger.kernel.org] On Behalf Of Leon Romanovsky
> Sent: Wednesday, May 04, 2016 12:36 AM
> To: dledford@redhat.com
> Cc: linux-rdma@vger.kernel.org; markb@mellanox.com; majd@mellanox.com;
> matanb@mellanox.com; Leon Romanovsky
> Subject: [PATCH rdma-next 1/4] IB/iwpm: Fix a potential skb leak
> 
> From: Mark Bloch <markb@mellanox.com>
> 
> 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>
> Signed-off-by: Leon Romanovsky <leon@kernel.org>
> ---
>  drivers/infiniband/core/iwpm_util.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/core/iwpm_util.c
> b/drivers/infiniband/core/iwpm_util.c
> index 9b2bf2f..b65e06c 100644
> --- a/drivers/infiniband/core/iwpm_util.c
> +++ b/drivers/infiniband/core/iwpm_util.c
> @@ -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;
> --
> 2.1.4

Looks good.

Reviewed-by: Steve Wise <swise@opengridcomputing.com>


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
index 9b2bf2f..b65e06c 100644
--- a/drivers/infiniband/core/iwpm_util.c
+++ b/drivers/infiniband/core/iwpm_util.c
@@ -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;