micrel: ksz8851: fixes struct pointer issue
authorJerry Ray <jerry.ray@microchip.com>
Mon, 22 Aug 2022 21:39:32 +0000 (16:39 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Aug 2022 12:02:15 +0000 (13:02 +0100)
commitfef5de753ff01887cfa50990532c3890fccb9338
tree22cf982db5eb608e762caa256752a231f55e5e6a
parentaacd467c0a576e5e44d2de4205855dc0fe43f6fb
micrel: ksz8851: fixes struct pointer issue

Issue found during code review. This bug has no impact as long as the
ks8851_net structure is the first element of the ks8851_net_spi structure.
As long as the offset to the ks8851_net struct is zero, the container_of()
macro is subtracting 0 and therefore no damage done. But if the
ks8851_net_spi struct is ever modified such that the ks8851_net struct
within it is no longer the first element of the struct, then the bug would
manifest itself and cause problems.

struct ks8851_net is contained within ks8851_net_spi.
ks is contained within kss.
kss is the priv_data of the netdev structure.

Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/micrel/ks8851_spi.c