Browse Source

can: dev: make can_change_state() robust to be called with cf == NULL

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>
Marc Kleine-Budde 8 years ago
parent
commit
ff3416fb5b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      drivers/net/can/dev.c

+ 3 - 0
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);
 	can_update_state_error_stats(dev, new_state);
 	priv->state = new_state;
 	priv->state = new_state;
 
 
+	if (!cf)
+		return;
+
 	if (unlikely(new_state == CAN_STATE_BUS_OFF)) {
 	if (unlikely(new_state == CAN_STATE_BUS_OFF)) {
 		cf->can_id |= CAN_ERR_BUSOFF;
 		cf->can_id |= CAN_ERR_BUSOFF;
 		return;
 		return;