From mboxrd@z Thu Jan 1 00:00:00 1970 From: Archit Taneja 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 Message-ID: <52B92B2C.1090806@ti.com> References: <1387812473-31696-1-git-send-email-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by gabe.freedesktop.org (Postfix) with ESMTP id 45AF110593B for ; Mon, 23 Dec 2013 22:35:40 -0800 (PST) In-Reply-To: <1387812473-31696-1-git-send-email-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Laurent Pinchart , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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 > --- > 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) { >