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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Dec 24 03:58:01 PST 2013


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 at ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Changes since v1:

- Use list_first_entry_or_null

diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index f2b8f06..2c3acb3 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -302,7 +302,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) {
-- 
Regards,

Laurent Pinchart



More information about the dri-devel mailing list