Skip to content

Commit 4a54903

Browse files
emuslndavem330
authored andcommitted
ionic: catch failure from devlink_alloc
Add a check for NULL on the alloc return. If devlink_alloc() fails and we try to use devlink_priv() on the NULL return, the kernel gets very unhappy and panics. With this fix, the driver load will still fail, but at least it won't panic the kernel. Fixes: df69ba4 ("ionic: Add basic framework for IONIC Network device driver") Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9ad685d commit 4a54903

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/net/ethernet/pensando/ionic/ionic_devlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct ionic *ionic_devlink_alloc(struct device *dev)
6161
struct devlink *dl;
6262

6363
dl = devlink_alloc(&ionic_dl_ops, sizeof(struct ionic), dev);
64+
if (!dl)
65+
return NULL;
6466

6567
return devlink_priv(dl);
6668
}

0 commit comments

Comments
 (0)