Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Coelho, Luciano" <luciano.coelho@intel.com>
To: "kamil.konieczny@linux.intel.com" <kamil.konieczny@linux.intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t v3 2/2] tests/intel/i915_pm_rpm: check drmModeGetConnector() before use
Date: Wed, 12 Jun 2024 14:10:56 +0000	[thread overview]
Message-ID: <64137841cd6f4d3f0c8b994664a46798effefa8a.camel@intel.com> (raw)
In-Reply-To: <20240607151123.4o66krb6y4kwyg5u@kamilkon-DESK.igk.intel.com>

On Fri, 2024-06-07 at 17:11 +0200, Kamil Konieczny wrote:
> Hi Luca,
> On 2024-05-30 at 11:59:08 +0300, Luca Coelho wrote:
> > 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 init_mode_set_data(), so fix that.
> > 
> > From the bug report:
> > 
> > Starting subtest: module-reload
> > Received signal SIGSEGV.
> > Stack trace:
> 
> Now I think that line 'Stack trace' is not needed, only those
> two with subtest name and signal are enough.

Okay... it's mostly noise IMHO, anyway.


> > Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10911
> > Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> > Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> > Cc: Jani Saarinen <jani.saarinen@intel.com>
> > Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
> > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > ---
> >  tests/intel/i915_pm_rpm.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/tests/intel/i915_pm_rpm.c b/tests/intel/i915_pm_rpm.c
> > index 0ea5fbd8afd9..e0f395fa8a84 100644
> > --- a/tests/intel/i915_pm_rpm.c
> > +++ b/tests/intel/i915_pm_rpm.c
> > @@ -515,6 +515,12 @@ static void init_mode_set_data(struct mode_set_data *data)
> >  			data->connectors[i] =
> >  				drmModeGetConnector(drm_fd,
> >  						    data->res->connectors[i]);
> > +			if (!data->connectors[i]) {
> > +				igt_warn("Could not read connector %u\n",
> ----------------^^^^^^^^
> igt_debug
> 
> > +					 data->res->connectors[i]);
> > +				continue;
> > +			}
> > +
> 
> We generally do not warn and fail a test in case some prerequistics
> are not present, that is why it is better to igt_debug here

This is not about pre-requisites.  This is about a race condition where
we get a larger number of connectors than what is actually available
later.

I think the test should fail in this case, because then we will look at
what is going on and try to figure out what's causing it.

I had igt_warn(), then you told me to change to igt_debug(), then you
told me to change it back to igt_warn() and now you're asking me to
change it to igt_debug, *again*?!


> and make checks in few other places, like:
> 			if (data->connectors[i]) {
>                     // here we can safely use/free connector or edid
>             }
> or
> 			if (!data->connectors[i])
>                 continue;

I don't get it.  Can you explain in more details?


> grep -n connectors tests/intel/i915_pm_rpm.c
> 139:    drmModeConnectorPtr connectors[MAX_CONNECTORS];
> 151:    drmModeConnectorPtr connectors[MAX_CONNECTORS];
> 319:    for (int i = 0; i < data->res->count_connectors; i++) {
> 320:            drmModeConnectorPtr c = data->connectors[i];
> 513:            igt_assert(data->res->count_connectors <= MAX_CONNECTORS);
> 514:            for (int i = 0; i < data->res->count_connectors; i++) {
> 515:                    data->connectors[i] =
> 517:                                                data->res->connectors[i]);
> 518:                    data->edids[i] = get_connector_edid(data->connectors[i], i);
> 531:            for (int i = 0; i < data->res->count_connectors; i++) {
> 532:                    drmModeFreeConnector(data->connectors[i]);
> 
> so all you need is add checks in lines after 320 and 531.

I don't think it's needed in 320, because with my change we're already
checking if the pointer was NULL when we _assigned_
data->connectors[i].  We should never get here with a NULL in the
table.

My change is about checking the return value of drmModeGetConnector(),
which can return NULL, so I checked all the callers and made sure they
check the return value.


> Btw test is missing final fixture with i915 module load but that
> should be fixed in separate patch.

Okay.

--
Cheers,
Luca.

  reply	other threads:[~2024-06-12 14:11 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 ` [PATCH i-g-t v3 1/2] lib/igt_chamelium: check drmModeGetConnector() before using Luca Coelho
2024-06-07 14:41   ` 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 [this message]
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=64137841cd6f4d3f0c8b994664a46798effefa8a.camel@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