[PATCH] Bluetooth: cmtp: Remove unnecessary null test

Subsystems: bluetooth subsystem, the rest

STALE4404d REVIEWED: 1 (0M)

1 review trailer.

2 messages, 2 authors, 2014-07-14 · open the first message on its own page

[PATCH] Bluetooth: cmtp: Remove unnecessary null test

From: Himangi Saraogi <hidden>
Date: 2014-07-14 20:34:24

This patch removes the null test on ctrl. ctrl is initialized at the
beginning of the function to &session->ctrl. Since session is
dereferenced prior to the null test, session must be a valid pointer,
and &session->ctrl cannot be null.

The following Coccinelle script is used for detecting the change:

@r@
expression e,f;
identifier g,y;
statement S1,S2;
@@

*e = &f->g
<+...
 f->y
 ...+>
*if (e != NULL || ...)
 S1 else S2

Signed-off-by: Himangi Saraogi <redacted>
Acked-by: Julia Lawall <redacted>
---
 net/bluetooth/cmtp/capi.c | 6 ------
 1 file changed, 6 deletions(-)
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index cd75e4d..1ca8a87 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -362,12 +362,6 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 		CAPIMSG_SETCONTROL(skb->data, contr);
 	}
 
-	if (!ctrl) {
-		BT_ERR("Can't find controller %d for message", session->num);
-		kfree_skb(skb);
-		return;
-	}
-
 	capi_ctr_handle_message(ctrl, appl, skb);
 }
 
-- 
1.9.1

Re: [PATCH] Bluetooth: cmtp: Remove unnecessary null test

From: Marcel Holtmann <marcel@holtmann.org>
Date: 2014-07-14 21:02:22

Hi Himangi,
This patch removes the null test on ctrl. ctrl is initialized at the
beginning of the function to &session->ctrl. Since session is
dereferenced prior to the null test, session must be a valid pointer,
and &session->ctrl cannot be null.

The following Coccinelle script is used for detecting the change:

@r@
expression e,f;
identifier g,y;
statement S1,S2;
@@

*e = &f->g
<+...
f->y
...+>
*if (e != NULL || ...)
S1 else S2

Signed-off-by: Himangi Saraogi <redacted>
Acked-by: Julia Lawall <redacted>
---
net/bluetooth/cmtp/capi.c | 6 ------
1 file changed, 6 deletions(-)
patch has been applied to bluetooth-next tree.

Regards

Marcel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help