]> git.itanic.dy.fi Git - linux-stable/commitdiff
ionic: catch failure from devlink_alloc
authorShannon Nelson <shannon.nelson@amd.com>
Tue, 2 May 2023 18:35:36 +0000 (11:35 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 09:50:18 +0000 (11:50 +0200)
[ 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>
drivers/net/ethernet/pensando/ionic/ionic_devlink.c

index c7d0e195d17607fe23f6dd5c68f588b9a5cf4da9..5c06decc868c498c0a1a0fad9f53b4992420228c 100644 (file)
@@ -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);
 }