Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c64863a authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Marc Kleine-Budde
Browse files

can: c_can: Do not access skb after net_receive_skb()



There is no guarantee that the skb is in the same state after calling
net_receive_skb(). It might be freed or reused. Not really harmful as
its a read access, except you turn on the proper debugging options
which catch a use after free.

The whole can subsystem is full of this. Copy and paste ....

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent ef1d2e28
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -429,10 +429,10 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
		}
		}
	}
	}


	netif_receive_skb(skb);

	stats->rx_packets++;
	stats->rx_packets++;
	stats->rx_bytes += frame->can_dlc;
	stats->rx_bytes += frame->can_dlc;

	netif_receive_skb(skb);
	return 0;
	return 0;
}
}


@@ -960,9 +960,9 @@ static int c_can_handle_state_change(struct net_device *dev,
		break;
		break;
	}
	}


	netif_receive_skb(skb);
	stats->rx_packets++;
	stats->rx_packets++;
	stats->rx_bytes += cf->can_dlc;
	stats->rx_bytes += cf->can_dlc;
	netif_receive_skb(skb);


	return 1;
	return 1;
}
}
@@ -1033,10 +1033,9 @@ static int c_can_handle_bus_err(struct net_device *dev,
	/* set a `lec` value so that we can check for updates later */
	/* set a `lec` value so that we can check for updates later */
	priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
	priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);


	netif_receive_skb(skb);
	stats->rx_packets++;
	stats->rx_packets++;
	stats->rx_bytes += cf->can_dlc;
	stats->rx_bytes += cf->can_dlc;

	netif_receive_skb(skb);
	return 1;
	return 1;
}
}