diff options
author | Shannon Nelson <shannon.nelson@amd.com> | 2023-05-02 20:35:36 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-05-03 10:14:47 +0200 |
commit | 4a54903ff68ddb33b6463c94b4eb37fc584ef760 (patch) | |
tree | 789c02e2a417037fc8ff45ebb69b8e8489e29f7e /drivers/net/ethernet/pensando | |
parent | ethtool: Fix uninitialized number of lanes (diff) | |
download | linux-4a54903ff68ddb33b6463c94b4eb37fc584ef760.tar.xz linux-4a54903ff68ddb33b6463c94b4eb37fc584ef760.zip |
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: df69ba43217d ("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>
Diffstat (limited to 'drivers/net/ethernet/pensando')
-rw-r--r-- | drivers/net/ethernet/pensando/ionic/ionic_devlink.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c index e6ff757895ab..4ec66a6be073 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c @@ -61,6 +61,8 @@ struct ionic *ionic_devlink_alloc(struct device *dev) struct devlink *dl; dl = devlink_alloc(&ionic_dl_ops, sizeof(struct ionic), dev); + if (!dl) + return NULL; return devlink_priv(dl); } |