kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/2] infiniband/cxgb4: add null check
@ 2010-05-31 14:01 Dan Carpenter
  2010-06-02 21:58 ` Roland Dreier
  2010-07-19 20:15 ` Roland Dreier
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Carpenter @ 2010-05-31 14:01 UTC (permalink / raw)
  To: Steve Wise
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Earlier in the function we assume that ep->com.cm_id can be null.  I
looked through the code briefly but couldn't tell if it actually is ever
null or not.  Adding a null check here seemed like a cautious thing to
do.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 60b5beb..9d11946 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -786,7 +786,8 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
 		ep->com.cm_id->event_handler(ep->com.cm_id, &event);
 	}
 	if (status < 0) {
-		ep->com.cm_id->rem_ref(ep->com.cm_id);
+		if (ep->com.cm_id)
+			ep->com.cm_id->rem_ref(ep->com.cm_id);
 		ep->com.cm_id = NULL;
 		ep->com.qp = NULL;
 	}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] infiniband/cxgb4: add null check
  2010-05-31 14:01 [patch 2/2] infiniband/cxgb4: add null check Dan Carpenter
@ 2010-06-02 21:58 ` Roland Dreier
       [not found]   ` <adaeigpqepg.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
  2010-07-19 20:15 ` Roland Dreier
  1 sibling, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2010-06-02 21:58 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

 >  	if (status < 0) {
 > -		ep->com.cm_id->rem_ref(ep->com.cm_id);
 > +		if (ep->com.cm_id)
 > +			ep->com.cm_id->rem_ref(ep->com.cm_id);

Steve, does this make sense?
-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] infiniband/cxgb4: add null check
       [not found]   ` <adaeigpqepg.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2010-06-03  2:46     ` Steve Wise
       [not found]       ` <4C07177C.5050502-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Wise @ 2010-06-03  2:46 UTC (permalink / raw)
  To: Roland Dreier
  Cc: Dan Carpenter, Steve Wise, Roland Dreier, Sean Hefty,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Roland Dreier wrote:
>  >  	if (status < 0) {
>  > -		ep->com.cm_id->rem_ref(ep->com.cm_id);
>  > +		if (ep->com.cm_id)
>  > +			ep->com.cm_id->rem_ref(ep->com.cm_id);
>
> Steve, does this make sense?
>   
I actually think that ep->com.cm_id is always valid when 
connect_reply_upcall() is called.  But I'd have to test it more.  I'd 
rather not add this change unless someone convinces me that there 
actually is a path where the cm_id null...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] infiniband/cxgb4: add null check
       [not found]       ` <4C07177C.5050502-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
@ 2010-06-03  5:22         ` Roland Dreier
       [not found]           ` <adaaarcr8qo.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2010-06-03  5:22 UTC (permalink / raw)
  To: Steve Wise
  Cc: Dan Carpenter, Steve Wise, Roland Dreier, Sean Hefty,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

 > I actually think that ep->com.cm_id is always valid when
 > connect_reply_upcall() is called.  But I'd have to test it more.  I'd
 > rather not add this change unless someone convinces me that there
 > actually is a path where the cm_id null...

Then would it make sense to change the code

	if (ep->com.cm_id) {
		PDBG("%s ep %p tid %u status %d\n", __func__, ep,
		     ep->hwtid, status);
		ep->com.cm_id->event_handler(ep->com.cm_id, &event);
	}

to just

	PDBG("%s ep %p tid %u status %d\n", __func__, ep,
	     ep->hwtid, status);
	ep->com.cm_id->event_handler(ep->com.cm_id, &event);

?
-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] infiniband/cxgb4: add null check
       [not found]           ` <adaaarcr8qo.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2010-06-03 14:38             ` Steve Wise
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Wise @ 2010-06-03 14:38 UTC (permalink / raw)
  To: Roland Dreier
  Cc: Dan Carpenter, Steve Wise, Roland Dreier, Sean Hefty,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Roland Dreier wrote:
>  > I actually think that ep->com.cm_id is always valid when
>  > connect_reply_upcall() is called.  But I'd have to test it more.  I'd
>  > rather not add this change unless someone convinces me that there
>  > actually is a path where the cm_id null...
>
> Then would it make sense to change the code
>
> 	if (ep->com.cm_id) {
> 		PDBG("%s ep %p tid %u status %d\n", __func__, ep,
> 		     ep->hwtid, status);
> 		ep->com.cm_id->event_handler(ep->com.cm_id, &event);
> 	}
>
> to just
>
> 	PDBG("%s ep %p tid %u status %d\n", __func__, ep,
> 	     ep->hwtid, status);
> 	ep->com.cm_id->event_handler(ep->com.cm_id, &event);
>
> ?
>   


Yes.  I haven't tested it though.    But if you wanna push it, then I'll 
test it here soon.

Steve.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch 2/2] infiniband/cxgb4: add null check
  2010-05-31 14:01 [patch 2/2] infiniband/cxgb4: add null check Dan Carpenter
  2010-06-02 21:58 ` Roland Dreier
@ 2010-07-19 20:15 ` Roland Dreier
  1 sibling, 0 replies; 6+ messages in thread
From: Roland Dreier @ 2010-07-19 20:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve Wise, Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Since we agreed the NULL check probably wasn't needed, I added this:

[PATCH] RDMA/cxgb4: Remove unneeded NULL check

The rest of the code seems to assume that ep->com.cm_id can't be NULL,
so remove an unneeded test.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
 drivers/infiniband/hw/cxgb4/cm.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index b5e676c..4185c3b 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -780,11 +780,11 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
 		event.private_data_len = ep->plen;
 		event.private_data = ep->mpa_pkt + sizeof(struct mpa_message);
 	}
-	if (ep->com.cm_id) {
-		PDBG("%s ep %p tid %u status %d\n", __func__, ep,
-		     ep->hwtid, status);
-		ep->com.cm_id->event_handler(ep->com.cm_id, &event);
-	}
+
+	PDBG("%s ep %p tid %u status %d\n", __func__, ep,
+	     ep->hwtid, status);
+	ep->com.cm_id->event_handler(ep->com.cm_id, &event);
+
 	if (status < 0) {
 		ep->com.cm_id->rem_ref(ep->com.cm_id);
 		ep->com.cm_id = NULL;
-- 
1.7.1.1


-- 
Roland Dreier <rolandd@cisco.com> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-19 20:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-31 14:01 [patch 2/2] infiniband/cxgb4: add null check Dan Carpenter
2010-06-02 21:58 ` Roland Dreier
     [not found]   ` <adaeigpqepg.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-06-03  2:46     ` Steve Wise
     [not found]       ` <4C07177C.5050502-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2010-06-03  5:22         ` Roland Dreier
     [not found]           ` <adaaarcr8qo.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-06-03 14:38             ` Steve Wise
2010-07-19 20:15 ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).