All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Oleksij Rempel <o.rempel@pengutronix.de>,
	syzbot+95c8e0d9dffde15b6c5c@syzkaller.appspotmail.com
Subject: [PATCH 3/9] can: j1939: main: j1939_ndev_to_priv(): avoid crash if can_ml_priv is NULL
Date: Wed, 13 Nov 2019 10:55:44 +0100	[thread overview]
Message-ID: <20191113095550.26527-4-mkl@pengutronix.de> (raw)
In-Reply-To: <20191113095550.26527-1-mkl@pengutronix.de>

From: Oleksij Rempel <o.rempel@pengutronix.de>

This patch avoids a NULL pointer deref crash if ndev->ml_priv is NULL.

Reported-by: syzbot+95c8e0d9dffde15b6c5c@syzkaller.appspotmail.com
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 net/can/j1939/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index def2f813ffce..8dc935dc2e54 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -207,6 +207,9 @@ static inline struct j1939_priv *j1939_ndev_to_priv(struct net_device *ndev)
 {
 	struct can_ml_priv *can_ml_priv = ndev->ml_priv;
 
+	if (!can_ml_priv)
+		return NULL;
+
 	return can_ml_priv->j1939_priv;
 }
 
-- 
2.24.0

  parent reply	other threads:[~2019-11-13  9:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13  9:55 pull-request: can 2019-11-13 Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 1/9] can: af_can: export can_sock_destruct() Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 2/9] can: j1939: move j1939_priv_put() into sk_destruct callback Marc Kleine-Budde
2019-11-13  9:55 ` Marc Kleine-Budde [this message]
2019-11-13  9:55 ` [PATCH 4/9] can: j1939: socket: rework socket locking for j1939_sk_release() and j1939_sk_sendmsg() Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 5/9] can: j1939: transport: make sure the aborted session will be deactivated only once Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 6/9] can: j1939: make sure socket is held as long as session exists Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 7/9] can: j1939: transport: j1939_cancel_active_session(): use hrtimer_try_to_cancel() instead of hrtimer_cancel() Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 8/9] can: j1939: j1939_can_recv(): add priv refcounting Marc Kleine-Budde
2019-11-13  9:55 ` [PATCH 9/9] can: j1939: warn if resources are still linked on destroy Marc Kleine-Budde
2019-11-13 19:47 ` pull-request: can 2019-11-13 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=20191113095550.26527-4-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=syzbot+95c8e0d9dffde15b6c5c@syzkaller.appspotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.