All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chia-I Wu <olvaffe@gmail.com>
To: Liu Zixian <liuzixian4@huawei.com>
Cc: linfeilong@huawei.com,
	ML dri-devel <dri-devel@lists.freedesktop.org>,
	"open list:VIRTIO CORE,
	NET AND BLOCK DRIVERS"
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes
Date: Thu, 24 Mar 2022 12:54:07 -0700	[thread overview]
Message-ID: <CAPaKu7QgGH2jhvBYZvOpyMXDf6xS_uvNkGADfdjHb4GVSCFeFg@mail.gmail.com> (raw)
In-Reply-To: <20220322081844.1602-1-liuzixian4@huawei.com>

On Wed, Mar 23, 2022 at 4:01 AM Liu Zixian <liuzixian4@huawei.com> 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
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: Chia-I Wu <olvaffe@gmail.com>
To: Liu Zixian <liuzixian4@huawei.com>
Cc: linfeilong@huawei.com,
	ML dri-devel <dri-devel@lists.freedesktop.org>,
	"open list:VIRTIO CORE,
	NET AND BLOCK DRIVERS"
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes
Date: Thu, 24 Mar 2022 12:54:07 -0700	[thread overview]
Message-ID: <CAPaKu7QgGH2jhvBYZvOpyMXDf6xS_uvNkGADfdjHb4GVSCFeFg@mail.gmail.com> (raw)
In-Reply-To: <20220322081844.1602-1-liuzixian4@huawei.com>

On Wed, Mar 23, 2022 at 4:01 AM Liu Zixian <liuzixian4@huawei.com> 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
>

  reply	other threads:[~2022-03-24 19:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22  8:18 [PATCH] drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes Liu Zixian
2022-03-24 19:54 ` Chia-I Wu [this message]
2022-03-24 19:54   ` Chia-I Wu
  -- strict thread matches above, loose matches on Subject: below --
2022-03-22  9:17 Liu Zixian
2022-03-22  9:17 ` Liu Zixian via Virtualization
2022-03-21  7:09 Liu Zixian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPaKu7QgGH2jhvBYZvOpyMXDf6xS_uvNkGADfdjHb4GVSCFeFg@mail.gmail.com \
    --to=olvaffe@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linfeilong@huawei.com \
    --cc=liuzixian4@huawei.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.