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: 0efeea5fb1 ("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>
This commit is contained in:
Yongzhi Liu 2022-05-19 05:09:48 -07:00 committed by Jakub Kicinski
parent ed46b3e127
commit eb4c078896
1 changed files with 4 additions and 1 deletions

View File

@ -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();