public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Vincent Stehlé" <vincent.stehle@laposte.net>
To: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Vincent Stehlé" <vincent.stehle@laposte.net>,
	"Thierry Escande" <thierry.escande@linux.intel.com>,
	"Samuel Ortiz" <sameo@linux.intel.com>
Subject: [PATCH] nfc: netlink: avoid NULL pointer dereference on error
Date: Wed,  7 Oct 2015 11:33:19 +0200	[thread overview]
Message-ID: <1444210399-3913-1-git-send-email-vincent.stehle@laposte.net> (raw)

The function nfc_genl_llc_sdreq() can dereference the dev pointer while
it is NULL on its error path. Create a new error handling label to avoid
that.

This fixes the following coccinelle error:

  ./net/nfc/netlink.c:1175:21-24: ERROR: dev is NULL but dereferenced.

Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Thierry Escande <thierry.escande@linux.intel.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 net/nfc/netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 853172c..51c48f0 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1111,7 +1111,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
 	dev = nfc_get_device(idx);
 	if (!dev) {
 		rc = -ENODEV;
-		goto exit;
+		goto exit_nodev;
 	}
 
 	device_lock(&dev->dev);
@@ -1176,6 +1176,7 @@ exit:
 
 	nfc_put_device(dev);
 
+exit_nodev:
 	return rc;
 }
 
-- 
2.5.1

             reply	other threads:[~2015-10-07  9:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-07  9:33 Vincent Stehlé [this message]
2015-10-20  4:50 ` [PATCH] nfc: netlink: avoid NULL pointer dereference on error Samuel Ortiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444210399-3913-1-git-send-email-vincent.stehle@laposte.net \
    --to=vincent.stehle@laposte.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=thierry.escande@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox