netdev.vger.kernel.org archive mirror
 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, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 1/6] can: dev: make can_change_state() robust to be called with cf == NULL
Date: Fri,  9 Jun 2017 14:55:08 +0200	[thread overview]
Message-ID: <20170609125513.24436-2-mkl@pengutronix.de> (raw)
In-Reply-To: <20170609125513.24436-1-mkl@pengutronix.de>

In OOM situations where no skb can be allocated, can_change_state() may
be called with cf == NULL. As this function updates the state and error
statistics it's not an option to skip the call to can_change_state() in
OOM situations.

This patch makes can_change_state() robust, so that it can be called
with cf == NULL.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 611d16a7061d..ae4ed03dc642 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -391,6 +391,9 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
 	can_update_state_error_stats(dev, new_state);
 	priv->state = new_state;
 
+	if (!cf)
+		return;
+
 	if (unlikely(new_state == CAN_STATE_BUS_OFF)) {
 		cf->can_id |= CAN_ERR_BUSOFF;
 		return;
-- 
2.11.0

  reply	other threads:[~2017-06-09 12:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 12:55 pull-request: can 2017-06-09 Marc Kleine-Budde
2017-06-09 12:55 ` Marc Kleine-Budde [this message]
2017-06-09 12:55 ` [PATCH 2/6] can: peak_canfd: fix uninitialized symbol warnings Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 3/6] can: peak_usb: fix product-id endianness in error message Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 4/6] can: gs_usb: fix memory leak in gs_cmd_reset() Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 5/6] can: af_can: namespace support: fix lockdep splat: properly initialize spin_lock Marc Kleine-Budde
2017-06-09 12:55 ` [PATCH 6/6] can: enable CAN FD for virtual CAN devices by default Marc Kleine-Budde
2017-06-09 19:42 ` pull-request: can 2017-06-09 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=20170609125513.24436-2-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 \
    /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).