From: Archit Taneja <archit@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/omap: Don't dereference list head when the connectors list is empty
Date: Tue, 24 Dec 2013 12:05:24 +0530 [thread overview]
Message-ID: <52B92B2C.1090806@ti.com> (raw)
In-Reply-To: <1387812473-31696-1-git-send-email-laurent.pinchart@ideasonboard.com>
Hi,
On Monday 23 December 2013 08:57 PM, Laurent Pinchart wrote:
> The connectors list iterator returns the list head when the list is
> empty. Fix it by returning NULL in that case.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/gpu/drm/omapdrm/omap_fb.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
> index f2b8f06..1b48cf2 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -301,8 +301,11 @@ struct drm_connector *omap_framebuffer_get_next_connector(
> struct list_head *connector_list = &dev->mode_config.connector_list;
> struct drm_connector *connector = from;
>
> - if (!from)
> + if (!from) {
> + if (list_empty(connector_list))
> + return NULL;
> return list_first_entry(connector_list, typeof(*from), head);
looks like there is a list function which does that too:
list_first_entry_or_null()
We could probably replace it with this.
Archit
> + }
>
> list_for_each_entry_from(connector, connector_list, head) {
> if (connector != from) {
>
prev parent reply other threads:[~2013-12-24 6:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-23 15:27 [PATCH] drm/omap: Don't dereference list head when the connectors list is empty Laurent Pinchart
2013-12-23 18:04 ` Rob Clark
2013-12-23 18:15 ` Laurent Pinchart
2013-12-24 6:35 ` Archit Taneja [this message]
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=52B92B2C.1090806@ti.com \
--to=archit@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox