* [PATCH v2 net] ionic: catch failure from devlink_alloc
@ 2023-05-02 18:35 Shannon Nelson
2023-05-02 20:00 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shannon Nelson @ 2023-05-02 18:35 UTC (permalink / raw)
To: kuba, davem, netdev; +Cc: drivers, Shannon Nelson
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>
---
v2 - fixed up the Fixes tag - thanks, Simon
https://lore.kernel.org/netdev/Y%2F8tj+bqGG1g5InQ@vergenet.net/
drivers/net/ethernet/pensando/ionic/ionic_devlink.c | 2 ++
1 file changed, 2 insertions(+)
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);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 net] ionic: catch failure from devlink_alloc
2023-05-02 18:35 [PATCH v2 net] ionic: catch failure from devlink_alloc Shannon Nelson
@ 2023-05-02 20:00 ` Simon Horman
2023-05-03 7:33 ` Jiri Pirko
2023-05-03 8:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-05-02 20:00 UTC (permalink / raw)
To: Shannon Nelson; +Cc: kuba, davem, netdev, drivers
On Tue, May 02, 2023 at 11:35:36AM -0700, Shannon Nelson wrote:
> 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>
> ---
> v2 - fixed up the Fixes tag - thanks, Simon
> https://lore.kernel.org/netdev/Y%2F8tj+bqGG1g5InQ@vergenet.net/
Likewise, thanks.
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2 net] ionic: catch failure from devlink_alloc
2023-05-02 18:35 [PATCH v2 net] ionic: catch failure from devlink_alloc Shannon Nelson
2023-05-02 20:00 ` Simon Horman
@ 2023-05-03 7:33 ` Jiri Pirko
2023-05-03 8:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2023-05-03 7:33 UTC (permalink / raw)
To: Shannon Nelson; +Cc: kuba, davem, netdev, drivers
Tue, May 02, 2023 at 08:35:36PM CEST, shannon.nelson@amd.com wrote:
>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: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2 net] ionic: catch failure from devlink_alloc
2023-05-02 18:35 [PATCH v2 net] ionic: catch failure from devlink_alloc Shannon Nelson
2023-05-02 20:00 ` Simon Horman
2023-05-03 7:33 ` Jiri Pirko
@ 2023-05-03 8:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-03 8:20 UTC (permalink / raw)
To: Shannon Nelson; +Cc: kuba, davem, netdev, drivers
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Tue, 2 May 2023 11:35:36 -0700 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [v2,net] ionic: catch failure from devlink_alloc
https://git.kernel.org/netdev/net/c/4a54903ff68d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-03 8:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 18:35 [PATCH v2 net] ionic: catch failure from devlink_alloc Shannon Nelson
2023-05-02 20:00 ` Simon Horman
2023-05-03 7:33 ` Jiri Pirko
2023-05-03 8:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox