Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luciano.coelho@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@linux.intel.com
Subject: [PATCH i-g-t v3 1/2] lib/igt_chamelium: check drmModeGetConnector() before using
Date: Thu, 30 May 2024 11:59:07 +0300	[thread overview]
Message-ID: <20240530085908.564733-2-luciano.coelho@intel.com> (raw)
In-Reply-To: <20240530085908.564733-1-luciano.coelho@intel.com>

The drmModeGetConnector() function can return NULL in some cases, so
we need to check the return value before accessing it.  This is not
being checked in wait_for_connected_state(), so fix that.

Cc: Mark Yacoub <markyacoub@chromium.org>
Cc: Manasi Navare <navaremanasi@chromium.org>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 lib/igt_chamelium.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 016d5356630c..620fbbf7d94f 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -524,6 +524,11 @@ static bool wait_for_connected_state(int drm_fd,
 			drmModeConnector *connector =
 				drmModeGetConnector(drm_fd, connectors[i]);
 
+			if (!connector) {
+				connected = false;
+				break;
+			}
+
 			connected = connector->connection == DRM_MODE_CONNECTED;
 
 			drmModeFreeConnector(connector);
-- 
2.39.2


  reply	other threads:[~2024-05-30  8:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-30  8:59 [PATCH i-g-t v3 0/2] check drmModeGetConnector() return value in some missing places Luca Coelho
2024-05-30  8:59 ` Luca Coelho [this message]
2024-06-07 14:41   ` [PATCH i-g-t v3 1/2] lib/igt_chamelium: check drmModeGetConnector() before using Kamil Konieczny
2024-06-12 13:58     ` Coelho, Luciano
2024-05-30  8:59 ` [PATCH i-g-t v3 2/2] tests/intel/i915_pm_rpm: check drmModeGetConnector() before use Luca Coelho
2024-06-07 15:11   ` Kamil Konieczny
2024-06-12 14:10     ` Coelho, Luciano
2024-06-13 13:32       ` Kamil Konieczny
2024-06-13 13:37         ` Coelho, Luciano
2024-05-30  9:59 ` ✓ CI.xeBAT: success for check drmModeGetConnector() return value in some missing places (rev4) Patchwork
2024-05-30 10:04 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-05-30 12:26   ` Luca Coelho
2024-05-31 16:53     ` Illipilli, TejasreeX
2024-05-30 10:57 ` ✗ CI.xeFULL: " Patchwork
2024-05-30 20:49   ` Luca Coelho
2024-05-31 16:50 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-02  1:30 ` ✗ Fi.CI.IGT: failure " Patchwork

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=20240530085908.564733-2-luciano.coelho@intel.com \
    --to=luciano.coelho@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.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