Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gvt: return error when failing to take the module reference

When we fail to take the module reference, we go to the 'undo*' branch and
return. But the returned variable 'ret' has been set as zero by the
above code. Change 'ret' to '-ENODEV' in this situation.

Fixes: 9bdb073464d6 ("drm/i915/gvt: Change KVMGT as self load module")
Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1605187352-51761-1-git-send-email-wangxiongfeng2@huawei.com

authored by

Xiongfeng Wang and committed by
Zhenyu Wang
4ec2b69d edb8d77a

+3 -1
+3 -1
drivers/gpu/drm/i915/gvt/kvmgt.c
··· 829 829 /* Take a module reference as mdev core doesn't take 830 830 * a reference for vendor driver. 831 831 */ 832 - if (!try_module_get(THIS_MODULE)) 832 + if (!try_module_get(THIS_MODULE)) { 833 + ret = -ENODEV; 833 834 goto undo_group; 835 + } 834 836 835 837 ret = kvmgt_guest_init(mdev); 836 838 if (ret)