2022-05-19 12:21:57

by Yongzhi Liu

[permalink] [raw]
Subject: [PATCH] hv_netvsc: Fix potential dereference of NULL pointer

The return value of netvsc_devinfo_get()
needs to be checked to avoid use of NULL
pointer in case of an allocation failure.

Fixes: 0efeea5fb ("hv_netvsc: Add the support of hibernation")

Signed-off-by: Yongzhi Liu <[email protected]>
---
drivers/net/hyperv/netvsc_drv.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index fde1c49..b1dece6 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2671,7 +2671,10 @@ static int netvsc_suspend(struct hv_device *dev)

/* Save the current config info */
ndev_ctx->saved_netvsc_dev_info = netvsc_devinfo_get(nvdev);
-
+ if (!ndev_ctx->saved_netvsc_dev_info) {
+ ret = -ENOMEM;
+ goto out;
+ }
ret = netvsc_detach(net, nvdev);
out:
rtnl_unlock();
--
2.7.4



2022-05-21 00:48:03

by Haiyang Zhang

[permalink] [raw]
Subject: RE: [PATCH] hv_netvsc: Fix potential dereference of NULL pointer



> -----Original Message-----
> From: Yongzhi Liu <[email protected]>
> Sent: Thursday, May 19, 2022 8:10 AM
> To: KY Srinivasan <[email protected]>; Haiyang Zhang
> <[email protected]>; Stephen Hemminger
> <[email protected]>; [email protected]; Dexuan Cui
> <[email protected]>; [email protected]; [email protected];
> [email protected]; [email protected]
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected]; Yongzhi Liu
> <[email protected]>
> Subject: [PATCH] hv_netvsc: Fix potential dereference of NULL pointer
>
> [Some people who received this message don't often get email from
> [email protected]. Learn why this is important at
> https://aka.ms/LearnAboutSenderIdentification.]
>
> The return value of netvsc_devinfo_get()
> needs to be checked to avoid use of NULL
> pointer in case of an allocation failure.
>
> Fixes: 0efeea5fb ("hv_netvsc: Add the support of hibernation")
>
> Signed-off-by: Yongzhi Liu <[email protected]>
> ---
> drivers/net/hyperv/netvsc_drv.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/hyperv/netvsc_drv.c
> b/drivers/net/hyperv/netvsc_drv.c
> index fde1c49..b1dece6 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -2671,7 +2671,10 @@ static int netvsc_suspend(struct hv_device *dev)
>
> /* Save the current config info */
> ndev_ctx->saved_netvsc_dev_info = netvsc_devinfo_get(nvdev);
> -
> + if (!ndev_ctx->saved_netvsc_dev_info) {
> + ret = -ENOMEM;
> + goto out;
> + }
> ret = netvsc_detach(net, nvdev);
> out:
> rtnl_unlock();

Reviewed-by: Haiyang Zhang <[email protected]>
Thank you!

2022-05-21 09:33:46

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] hv_netvsc: Fix potential dereference of NULL pointer

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

On Thu, 19 May 2022 05:09:48 -0700 you wrote:
> The return value of netvsc_devinfo_get()
> needs to be checked to avoid use of NULL
> pointer in case of an allocation failure.
>
> Fixes: 0efeea5fb ("hv_netvsc: Add the support of hibernation")
>
> Signed-off-by: Yongzhi Liu <[email protected]>
>
> [...]

Here is the summary with links:
- hv_netvsc: Fix potential dereference of NULL pointer
https://git.kernel.org/netdev/net/c/eb4c07889647

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html