b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Colin Ian King <colin.king@canonical.com>,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [B.A.T.M.A.N.] [PATCH 1/4] batman-adv: don't pass a NULL hard_iface to batadv_hardif_put
Date: Thu, 24 May 2018 13:53:22 +0200	[thread overview]
Message-ID: <20180524115325.15355-2-sw@simonwunderlich.de> (raw)
In-Reply-To: <20180524115325.15355-1-sw@simonwunderlich.de>

From: Colin Ian King <colin.king@canonical.com>

In the case where hard_iface is NULL, the error path may pass a null
pointer to batadv_hardif_put causing a null pointer dereference error.
Avoid this by only calling the function if  hard_iface not null.

Detected by CoverityScan, CID#1466456 ("Explicit null dereferenced")

Fixes: 53dd9a68ba68 ("batman-adv: add multicast flags netlink support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/multicast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index a11d3d89f012..a35f597e8c8b 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -1536,7 +1536,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback *cb,
 
 	if (!ret && primary_if)
 		*primary_if = hard_iface;
-	else
+	else if (hard_iface)
 		batadv_hardif_put(hard_iface);
 
 	return ret;
-- 
2.11.0


  reply	other threads:[~2018-05-24 11:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 11:53 [B.A.T.M.A.N.] [PATCH 0/4] pull request for net: batman-adv 2018-05-24 Simon Wunderlich
2018-05-24 11:53 ` Simon Wunderlich [this message]
2018-05-24 11:53 ` [B.A.T.M.A.N.] [PATCH 2/4] batman-adv: Avoid race in TT TVLV allocator helper Simon Wunderlich
2018-05-24 11:53 ` [B.A.T.M.A.N.] [PATCH 3/4] batman-adv: Fix TT sync flags for intermediate TT responses Simon Wunderlich
2018-05-24 11:53 ` [B.A.T.M.A.N.] [PATCH 4/4] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs Simon Wunderlich
2018-05-25 18:54 ` [B.A.T.M.A.N.] [PATCH 0/4] pull request for net: batman-adv 2018-05-24 David Miller

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=20180524115325.15355-2-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sven@narfation.org \
    /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;
as well as URLs for NNTP newsgroup(s).