Re: [PATCH] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes

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

 



On Wed, Mar 23, 2022 at 4:01 AM Liu Zixian <liuzixian4@xxxxxxxxxx> wrote:
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index 5b00310ac..f73352e7b 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -179,6 +179,8 @@ static int virtio_gpu_conn_get_modes(struct drm_connector *connector)
>                 DRM_DEBUG("add mode: %dx%d\n", width, height);
>                 mode = drm_cvt_mode(connector->dev, width, height, 60,
>                                     false, false, false);
> +               if (!mode)
> +                       return count;
>                 mode->type |= DRM_MODE_TYPE_PREFERRED;
>                 drm_mode_probed_add(connector, mode);
>                 count++;
Can we avoid early return here?  Something like

  mode = drm_cvt_mode(...);
  if (mode) {
    DRM_DEBUG("add mode: %dx%d\n", width, height);
    mode->type |= DRM_MODE_TYPE_PREFERRED
    drm_mode_probed_add(connector, mode);
    count++;
  }

is more future proof.

> --
> 2.33.0
>



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux