infiniband: Fixes memory leak in send_flowc
Subsystems (2)
PATCH 1/1 infiniband: Fixes memory leak in send_flowc
--- drivers/infiniband/hw/cxgb4/cm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/cm.c +4 -1
@@ -455,8 +455,11 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb)unsigned int flowclen =80 ;struct fw_flowc_wr *flowc;int i; - skb =get_skb (skb, flowclen,GFP_KERNEL ); +if (!skb) { +kfree_skb (skb); +return ; + } flowc = (struct fw_flowc_wr *)__skb_put (skb, flowclen); flowc->op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Nicholas Krause
Signed-off-by Nicholas Krause <[email protected]>--- drivers/infiniband/hw/cxgb4/cm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/hw/cxgb4/cm.c +0
-0
drivers/infiniband/hw/cxgb4/cm.c static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb) · line 458
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +0
-1@@ -455,8 +455,11 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb)unsigned int flowclen =80 ;struct fw_flowc_wr *flowc;int i; -
Please add back the above blank line.
drivers/infiniband/hw/cxgb4/cm.c static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb) · line 460
Quoted 3 lines
drivers/infiniband/hw/cxgb4/cm.c +2
-0skb =get_skb (skb, flowclen,GFP_KERNEL ); +if (!skb) { +kfree_skb (skb);
Let's do a pr_warn() here;
pr_warn(MOD "%s failed to allocate skb.\n", __func__);
Quoted 5 lines
drivers/infiniband/hw/cxgb4/cm.c +2
-0+return ; + } flowc = (struct fw_flowc_wr *)__skb_put (skb, flowclen); flowc->op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
Quoted 20 lines · Steve Wise
Quoted 11 lines · Nicholas Krause
Signed-off-by Nicholas Krause <[email protected]>--- drivers/infiniband/hw/cxgb4/cm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/hw/cxgb4/cm.c +0
-0drivers/infiniband/hw/cxgb4/cm.c static void send_flowc(struct c4iw_ep *ep, struct · line 459
Quoted 5 lines
drivers/infiniband/hw/cxgb4/cm.c +0
-1@@ -455,8 +455,11 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb)unsigned int flowclen =80 ;struct fw_flowc_wr *flowc;int i; -Please add back the above blank line.
Quoted 8 lines
drivers/infiniband/hw/cxgb4/cm.c static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb) · line 460
Quoted 3 lines
drivers/infiniband/hw/cxgb4/cm.c +2
-0skb =get_skb (skb, flowclen,GFP_KERNEL ); +if (!skb) { +kfree_skb (skb);Let's do a
pr_warn()here;pr_warn(MOD "%s failed to allocate skb.\n", __func__);
No need, if the allocation from skbuff_head_cache fails in the slab allocator, the page allocator will loop forever for orders less than PAGE_ALLOC_COSTLY_ORDER or spew a page allocation failure warning with a stack trace that indicated the high order page allocation failed in this path.
Quoted 5 lines
drivers/infiniband/hw/cxgb4/cm.c static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb) · line 465
Quoted 5 lines
drivers/infiniband/hw/cxgb4/cm.c +2
-0+return ; + } flowc = (struct fw_flowc_wr *)__skb_put (skb, flowclen); flowc->op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Nick Krause
If that is the case ,David I would mark bug id 44631 as closed due to no need for my if statement.
You don't want to depend on the implementation of the page allocator to never return NULL for orders < PAGE_ALLOC_COSTLY_ORDER with GFP_KERNEL, it could possibly change in the future and we wouldn't catch your dependency in send_flowc(). The size object size of the skbuff_head_cache slab cache could also change. You don't need the suggested pr_warn(), though, since the page allocation failure warning would also be noisy enough. --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Nick Krause
That's true David,
I will resend this parch without the use of thepr_warn.
There's no patch to resend if you don't use pr_warn(). kfree_skb(skb) is unnecessary if !skb, look at the first thing it checks:
void kfree_skb(struct sk_buff *skb)
{
if (unlikely(!skb))
return;
...
}Thus, I don't see the memory leak you're referring to.
Quoted 19 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of David Rientjes
Sent: Monday, June 16, 2014 7:37 PM
To: Nick Krause
Cc: Steve Wise; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] infiniband: Fixes memory leak insend_flowcQuoted 2 lines · Nick Krause
That's true David,
I will resend this parch without the use of thepr_warn.There's no patch to resend if you don't use
pr_warn().kfree_skb(skb)is unnecessary if !skb, look at the first thing it checks:
Quoted 8 lines
void
kfree_skb(struct sk_buff *skb){ if (unlikely(!skb)) return; ... }Thus, I don't see the memory leak you're referring to.
send_flowc() still needs to handle a NULL return from get_skb(). That is what the bug report is addressing...
Steve.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html