summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorShannon Nelson <shannon.nelson@amd.com>2023-05-02 11:35:36 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-17 11:50:18 +0200
commitc177dd465f5c1e5f242cdb9258826c591c257e9a (patch)
tree734b56bfd9b5284f8ed96b5c2abdb602de0713a3 /drivers
parentda81af0ef8092ecacd87fac3229c29e2e0ce39fd (diff)
downloadlinux-c177dd465f5c1e5f242cdb9258826c591c257e9a.tar.gz
linux-c177dd465f5c1e5f242cdb9258826c591c257e9a.tar.bz2
linux-c177dd465f5c1e5f242cdb9258826c591c257e9a.zip
ionic: catch failure from devlink_alloc
[ Upstream commit 4a54903ff68ddb33b6463c94b4eb37fc584ef760 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/pensando/ionic/ionic_devlink.c2
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 c7d0e195d176..5c06decc868c 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
@@ -65,6 +65,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);
}