drm/omap: Don't dereference list head when the connectors list is empty
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 24 Dec 2013 11:58:01 +0000 (12:58 +0100)
committerRob Clark <robdclark@gmail.com>
Mon, 31 Mar 2014 15:06:51 +0000 (11:06 -0400)
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>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/omapdrm/omap_fb.c

index f466c4aaee9464c7ca4c16d684a4e7d4bfec5584..19a9b8613620dd45e614165fc44c580298f6b442 100644 (file)
@@ -306,7 +306,8 @@ struct drm_connector *omap_framebuffer_get_next_connector(
        struct drm_connector *connector = from;
 
        if (!from)
-               return list_first_entry(connector_list, typeof(*from), head);
+               return list_first_entry_or_null(connector_list, typeof(*from),
+                                               head);
 
        list_for_each_entry_from(connector, connector_list, head) {
                if (connector != from) {