]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commite23e77f73ddafc723b1ac0ce0e00461f3acd0c09
tree22cf982db5eb608e762caa256752a231f55e5e6a
parente86d5b98b77db73880ae54e1b5d7ec3a30008060
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