Re: [RFC 07/14] vfio/nvgrace-egm: Register auxiliary driver ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 04, 2025 at 04:08:21AM +0000, ankita@xxxxxxxxxx wrote:
> +static const struct auxiliary_device_id egm_id_table[] = {
> +	{ .name = "nvgrace_gpu_vfio_pci.egm" },
> +	{ .name = "nvidia_vgpu_vfio.egm" },

Not in tree

>  static char *egm_devnode(const struct device *device, umode_t *mode)
>  {
>  	if (mode)
> @@ -35,19 +59,28 @@ static int __init nvgrace_egm_init(void)
>  
>  	class = class_create(NVGRACE_EGM_DEV_NAME);
>  	if (IS_ERR(class)) {
> -		unregister_chrdev_region(dev, MAX_EGM_NODES);
> -		return PTR_ERR(class);
> +		ret = PTR_ERR(class);
> +		goto unregister_chrdev;
>  	}
>  
>  	class->devnode = egm_devnode;
>  
> -	return 0;
> +	ret = auxiliary_driver_register(&egm_driver);
> +	if (!ret)
> +		goto fn_exit;
> +
> +	class_destroy(class);
> +unregister_chrdev:
> +	unregister_chrdev_region(dev, MAX_EGM_NODES);
> +fn_exit:
> +	return ret;
>  }
>  
>  static void __exit nvgrace_egm_cleanup(void)
>  {
>  	class_destroy(class);
>  	unregister_chrdev_region(dev, MAX_EGM_NODES);
> +	auxiliary_driver_unregister(&egm_driver);
>  }

Out of order, the order should be the reverse of init. This will UAF
the class as-is.

Jason




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux