diff mbox series

[v2,net] ionic: catch failure from devlink_alloc

Message ID 20230502183536.22256-1-shannon.nelson@amd.com (mailing list archive)
State Accepted
Commit 4a54903ff68ddb33b6463c94b4eb37fc584ef760
Delegated to: Netdev Maintainers
Headers show
Series [v2,net] ionic: catch failure from devlink_alloc | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 6 maintainers not CCed: brett.creeley@amd.com pabeni@redhat.com jiri@resnulli.us jacob.e.keller@intel.com edumazet@google.com mailhol.vincent@wanadoo.fr
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Nelson, Shannon May 2, 2023, 6:35 p.m. UTC
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(+)

Comments

Simon Horman May 2, 2023, 8 p.m. UTC | #1
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>
Jiri Pirko May 3, 2023, 7:33 a.m. UTC | #2
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>
patchwork-bot+netdevbpf@kernel.org May 3, 2023, 8:20 a.m. UTC | #3
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!
diff mbox series

Patch

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);
 }