Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/xe/configfs: Allow to select by class only
@ 2025-09-23  7:22 Dan Carpenter
  2025-09-23 15:21 ` Lucas De Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-09-23  7:22 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

Hello Lucas De Marchi,

Commit e2a9854d806e ("drm/xe/configfs: Allow to select by class
only") from Sep 16, 2025 (linux-next), leads to the following Smatch
static checker warning:

	drivers/gpu/drm/xe/xe_configfs.c:331 lookup_engine_info()
	error: we previously assumed 'mask' could be null (see line 327)

drivers/gpu/drm/xe/xe_configfs.c
    317 static const struct engine_info *lookup_engine_info(const char *pattern, u64 *mask)
    318 {
    319         for (size_t i = 0; i < ARRAY_SIZE(engine_info); i++) {
    320                 u8 instance;
    321                 u16 bit;
    322 
    323                 if (!str_has_prefix(pattern, engine_info[i].cls))
    324                         continue;
    325 
    326                 pattern += strlen(engine_info[i].cls);
    327                 if (!mask && !*pattern)
                                  ^^
Presumably this should be || instead of &&.  If mask is NULL the
function can't succeed.

    328                         return &engine_info[i];
    329 
    330                 if (!strcmp(pattern, "*")) {
--> 331                         *mask = engine_info[i].mask;
    332                         return &engine_info[i];
    333                 }
    334 
    335                 if (kstrtou8(pattern, 10, &instance))
    336                         return NULL;
    337 
    338                 bit = __ffs64(engine_info[i].mask) + instance;
    339                 if (bit >= fls64(engine_info[i].mask))
    340                         return NULL;
    341 
    342                 *mask = BIT_ULL(bit);
    343                 return &engine_info[i];
    344         }
    345 
    346         return NULL;
    347 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] drm/xe/configfs: Allow to select by class only
  2025-09-23  7:22 [bug report] drm/xe/configfs: Allow to select by class only Dan Carpenter
@ 2025-09-23 15:21 ` Lucas De Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2025-09-23 15:21 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: intel-xe

On Tue, Sep 23, 2025 at 10:22:06AM +0300, Dan Carpenter wrote:
>Hello Lucas De Marchi,
>
>Commit e2a9854d806e ("drm/xe/configfs: Allow to select by class
>only") from Sep 16, 2025 (linux-next), leads to the following Smatch
>static checker warning:
>
>	drivers/gpu/drm/xe/xe_configfs.c:331 lookup_engine_info()
>	error: we previously assumed 'mask' could be null (see line 327)
>
>drivers/gpu/drm/xe/xe_configfs.c
>    317 static const struct engine_info *lookup_engine_info(const char *pattern, u64 *mask)
>    318 {
>    319         for (size_t i = 0; i < ARRAY_SIZE(engine_info); i++) {
>    320                 u8 instance;
>    321                 u16 bit;
>    322
>    323                 if (!str_has_prefix(pattern, engine_info[i].cls))
>    324                         continue;
>    325
>    326                 pattern += strlen(engine_info[i].cls);
>    327                 if (!mask && !*pattern)
>                                  ^^
>Presumably this should be || instead of &&.  If mask is NULL the
>function can't succeed.

adding || here would create 2 other bugs, but yes, there's a bug here
fixed by https://lore.kernel.org/intel-xe/20250922221209.110737-2-lucas.demarchi@intel.com/
I will probably merge that later today.

thanks
Lucas De Marchi


>
>    328                         return &engine_info[i];
>    329
>    330                 if (!strcmp(pattern, "*")) {
>--> 331                         *mask = engine_info[i].mask;
>    332                         return &engine_info[i];
>    333                 }
>    334
>    335                 if (kstrtou8(pattern, 10, &instance))
>    336                         return NULL;
>    337
>    338                 bit = __ffs64(engine_info[i].mask) + instance;
>    339                 if (bit >= fls64(engine_info[i].mask))
>    340                         return NULL;
>    341
>    342                 *mask = BIT_ULL(bit);
>    343                 return &engine_info[i];
>    344         }
>    345
>    346         return NULL;
>    347 }
>
>regards,
>dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-23 15:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23  7:22 [bug report] drm/xe/configfs: Allow to select by class only Dan Carpenter
2025-09-23 15:21 ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox