Message ID | 20241028-ncsi-fixes-v1-1-f0bcfaf6eb88@codeconstruct.com.au (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: ncsi: minor fixes | expand |
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 5cf55bde366d1813865ac5da17d232b5eadb2a3e..647d12fde693114cfe3970e75546df48ad4c335e 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -1789,8 +1789,8 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev, ndp->ptype.dev = dev; dev_add_pack(&ndp->ptype); - pdev = to_platform_device(dev->dev.parent); - if (pdev) { + if (dev->dev.parent && dev_is_platform(dev->dev.parent)) { + pdev = to_platform_device(dev->dev.parent); np = pdev->dev.of_node; if (np && (of_property_read_bool(np, "mellanox,multi-host") || of_property_read_bool(np, "mlx,multi-host")))
The ncsi driver currently does a: pdev = to_platform_device(dev->dev.parent); if (pdev) { However, dev->dev.parent may be null, and to_platform_device() will not catch this case as intended by the conditional. Instead, check that dev->dev.parent is present, and is a platform_device, before converting. Fixes: 5e0fcc16e5c5 ("net/ncsi: Support for multi host mellanox card") Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> --- net/ncsi/ncsi-manage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)