Re: [PATCH] drm/omap: Don't dereference list head when the connectors list is empty

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

 



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@xxxxxxxxxxxxxxxx>
---
  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) {


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[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