netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFC: nci: hci: Fix releasing uninitialized skbs
@ 2015-06-01  0:44 Joe Perches
  2015-06-08 21:49 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2015-06-01  0:44 UTC (permalink / raw)
  To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz
  Cc: David S. Miller, linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel

Several of these goto exit; uses should be direct returns
as skb is not yet initialized by nci_hci_get_param().

Miscellanea:

o Use !memcmp instead of memcmp() == 0
o Remove unnecessary goto from if () {... goto exit;} else {...} exit:

Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
---
 net/nfc/nci/hci.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/nfc/nci/hci.c b/net/nfc/nci/hci.c
index ed54ec5..af002df 100644
--- a/net/nfc/nci/hci.c
+++ b/net/nfc/nci/hci.c
@@ -639,22 +639,19 @@ int nci_hci_dev_session_init(struct nci_dev *ndev)
 				 ndev->hci_dev->init_data.gates[0].gate,
 				 ndev->hci_dev->init_data.gates[0].pipe);
 	if (r < 0)
-		goto exit;
+		return r;
 
 	r = nci_hci_get_param(ndev, NCI_HCI_ADMIN_GATE,
 			      NCI_HCI_ADMIN_PARAM_SESSION_IDENTITY, &skb);
 	if (r < 0)
-		goto exit;
+		return r;
 
 	if (skb->len &&
 	    skb->len == strlen(ndev->hci_dev->init_data.session_id) &&
-	    memcmp(ndev->hci_dev->init_data.session_id,
-		   skb->data, skb->len) == 0 &&
+	    !memcmp(ndev->hci_dev->init_data.session_id, skb->data, skb->len) &&
 	    ndev->ops->hci_load_session) {
 		/* Restore gate<->pipe table from some proprietary location. */
 		r = ndev->ops->hci_load_session(ndev);
-		if (r < 0)
-			goto exit;
 	} else {
 		r = nci_hci_dev_connect_gates(ndev,
 					      ndev->hci_dev->init_data.gate_count,
@@ -667,8 +664,6 @@ int nci_hci_dev_session_init(struct nci_dev *ndev)
 				      ndev->hci_dev->init_data.session_id,
 				      strlen(ndev->hci_dev->init_data.session_id));
 	}
-	if (r == 0)
-		goto exit;
 
 exit:
 	kfree_skb(skb);


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

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

* Re: [PATCH] NFC: nci: hci: Fix releasing uninitialized skbs
  2015-06-01  0:44 [PATCH] NFC: nci: hci: Fix releasing uninitialized skbs Joe Perches
@ 2015-06-08 21:49 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2015-06-08 21:49 UTC (permalink / raw)
  To: Joe Perches
  Cc: Lauro Ramos Venancio, Aloisio Almeida Jr, David S. Miller,
	linux-wireless, netdev, linux-kernel

Hi Joe,

On Sun, May 31, 2015 at 05:44:45PM -0700, Joe Perches wrote:
> Several of these goto exit; uses should be direct returns
> as skb is not yet initialized by nci_hci_get_param().
> 
> Miscellanea:
> 
> o Use !memcmp instead of memcmp() == 0
> o Remove unnecessary goto from if () {... goto exit;} else {...} exit:
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  net/nfc/nci/hci.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
Applied to nfc-next, thanks.

Cheers,
Samuel.

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

end of thread, other threads:[~2015-06-08 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01  0:44 [PATCH] NFC: nci: hci: Fix releasing uninitialized skbs Joe Perches
2015-06-08 21:49 ` Samuel Ortiz

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).