Skip to content

Commit

Permalink
hv_netvsc: Fix potential dereference of NULL pointer
Browse files Browse the repository at this point in the history
[ Upstream commit eb4c078 ]

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

Fixes: 0efeea5 ("hv_netvsc: Add the support of hibernation")
Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Link: https://lore.kernel.org/r/1652962188-129281-1-git-send-email-lyz_cs@pku.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hyperlyz authored and gregkh committed Jun 9, 2022
1 parent deb16df commit 5412242
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/hyperv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,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();
Expand Down

0 comments on commit 5412242

Please sign in to comment.