linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings
@ 2022-02-08 11:22 Dan Carpenter
  2022-02-09 15:09 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-02-08 11:22 UTC (permalink / raw)
  To: kim.phillips; +Cc: linux-perf-users

Hello Kim Phillips,

This is a semi-automatic email about new static checker warnings.

The patch 9fe8895a27a8: "perf env: Add perf_env__cpuid,
perf_env__{nr_}pmu_mappings" from Aug 17, 2021, leads to the
following Smatch complaint:

    ./tools/perf/util/env.c:476 perf_env__nr_pmu_mappings()
    error: we previously assumed 'env' could be null (see line 470)

./tools/perf/util/env.c
   469	
   470		if (!env || !env->nr_pmu_mappings) { /* Assume local operation */
                     ^^^
Checks for NULL

   471			status = perf_env__read_pmu_mappings(env);
   472			if (status)
   473				return 0;
   474		}
   475	
   476		return env->nr_pmu_mappings;
                       ^^^^
Unchecked dereference

   477	}

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [bug report] perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings
@ 2022-07-18 13:15 Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-07-18 13:15 UTC (permalink / raw)
  To: kim.phillips; +Cc: linux-perf-users

Hello Kim Phillips,

This is a semi-automatic email about new static checker warnings.

The patch 9fe8895a27a8: "perf env: Add perf_env__cpuid,
perf_env__{nr_}pmu_mappings" from Aug 17, 2021, leads to the
following Smatch complaint:

    tools/perf/util/env.c:467 perf_env__cpuid()
    error: we previously assumed 'env' could be null (see line 461)

tools/perf/util/env.c
   457  const char *perf_env__cpuid(struct perf_env *env)
   458  {
   459          int status;
   460  
   461          if (!env || !env->cpuid) { /* Assume local operation */
   462                  status = perf_env__read_cpuid(env);
   463                  if (status)
   464                          return NULL;

If env is NULL and perf_env__read_cpuid() return zero then we are
toasted.

   465          }
   466  
   467          return env->cpuid;
   468  }

A couple of the neighboring functions are written the same way.  I'm not
sure why they don't generate checker warnings.

regards,
dan carpenter

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

end of thread, other threads:[~2022-07-18 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 11:22 [bug report] perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings Dan Carpenter
2022-02-09 15:09 ` Jiri Olsa
  -- strict thread matches above, loose matches on Subject: below --
2022-07-18 13:15 Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).