Re: [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails

From: Oarora Etimis

Date: Fri Nov 27 2026 - 02:21:51 EST


From: Oarora Etimis <oaroraetimis@xxxxxxxxx>, To: Louis Chauvet <louis.chauvet@xxxxxxxxxxx>

On Thu, Nov 26, 2026 at 12:28:53PM +0100, Louis Chauvet wrote:
> vkms_create() stores the vkms_device in config->dev, but the error paths
> after that point free the device (through devres_release_group()) without
> clearing the pointer. The configuration then keeps a dangling pointer,
> which can be dereferenced later (for example by vkms_destroy() or by the
> configfs disable path) once the device is already gone.
>
> Clear config->dev in the out_devres error path so the configuration stays
> consistent when the device creation fails.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx>
> ---
> drivers/gpu/drm/vkms/vkms_drv.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 28b99511f186..4cbb1173fcc6 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -215,6 +215,7 @@ int vkms_create(struct vkms_config *config)
>
> out_devres:
> devres_release_group(&fdev->dev, NULL);
> + config->dev = NULL;
> out_unregister:
> faux_device_destroy(fdev);
> return ret;
>
> --
> 2.56.0
>

Reviewed-by: Oarora Etimis <oaroraetimis@xxxxxxxxx>