[dm-devel] [bug report] dm mpath: add IO affinity path selector

Dan Carpenter dan.carpenter at oracle.com
Fri Nov 13 12:09:21 UTC 2020


Hello Mike Christie,

The patch c3d0a31e609e: "dm mpath: add IO affinity path selector"
from Oct 22, 2020, leads to the following static checker warning:

	drivers/md/dm-ps-io-affinity.c:56 ioa_add_path()
	error: uninitialized symbol 'cpu'.

drivers/md/dm-ps-io-affinity.c
    43  static int ioa_add_path(struct path_selector *ps, struct dm_path *path,
    44                          int argc, char **argv, char **error)
    45  {
    46          struct selector *s = ps->context;
    47          struct path_info *pi = NULL;
    48          unsigned int cpu;
                ^^^^^^^^^^^^^^^^

    49          int ret;
    50  
    51          if (argc != 1) {
    52                  *error = "io-affinity ps: invalid number of arguments";
    53                  return -EINVAL;
    54          }
    55  
    56          pi = kzalloc_node(sizeof(*pi), GFP_KERNEL, cpu_to_node(cpu));
                                                                       ^^^
Unintialized

    57          if (!pi) {
    58                  *error = "io-affinity ps: Error allocating path context";
    59                  return -ENOMEM;
    60          }
    61  
    62          pi->path = path;
    63          path->pscontext = pi;
    64          refcount_set(&pi->refcount, 1);
    65  
    66          if (!zalloc_cpumask_var(&pi->cpumask, GFP_KERNEL)) {
    67                  *error = "io-affinity ps: Error allocating cpumask context";
    68                  ret = -ENOMEM;
    69                  goto free_pi;
    70          }
    71  
    72          ret = cpumask_parse(argv[0], pi->cpumask);
    73          if (ret) {
    74                  *error = "io-affinity ps: invalid cpumask";
    75                  ret = -EINVAL;
    76                  goto free_mask;
    77          }
    78  
    79          for_each_cpu(cpu, pi->cpumask) {
    80                  if (cpu >= nr_cpu_ids) {
    81                          DMWARN_LIMIT("Ignoring mapping for CPU %u. Max CPU is %u\n",
    82                                       cpu, nr_cpu_ids);
    83                          break;
    84                  }
    85  
    86                  if (s->path_map[cpu]) {
    87                          DMWARN("CPU mapping for %u exists. Ignoring.", cpu);
    88                          continue;
    89                  }
    90  
    91                  cpumask_set_cpu(cpu, s->path_mask);
    92                  s->path_map[cpu] = pi;
    93                  refcount_inc(&pi->refcount);
    94                  continue;
    95          }
    96  
    97          if (refcount_dec_and_test(&pi->refcount)) {
    98                  *error = "io-affinity ps: No new/valid CPU mapping found";
    99                  ret = -EINVAL;
   100                  goto free_mask;
   101          }
   102  
   103          return 0;
   104  
   105  free_mask:
   106          free_cpumask_var(pi->cpumask);
   107  free_pi:
   108          kfree(pi);
   109          return ret;

regards,
dan carpenter




More information about the dm-devel mailing list