All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Colin Ian King <colin.king@canonical.com>,
	Mike Christie <michael.christie@oracle.com>
Cc: dm-devel@redhat.com, Alasdair Kergon <agk@redhat.com>
Subject: Re: [dm-devel] dm: rename multipath path selector source files to have "dm-ps" prefix
Date: Wed, 11 Nov 2020 10:24:36 -0500	[thread overview]
Message-ID: <20201111152436.GA22834@redhat.com> (raw)
In-Reply-To: <c5c17cba-3bf2-ce07-ed7f-6e5b5e71427c@canonical.com>

On Wed, Nov 11 2020 at  6:45am -0500,
Colin Ian King <colin.king@canonical.com> wrote:

> Hi,
> 
> Static analysis on linux-next has detected an initialized variable issue
> with the following recent commit:
> 
> commit 28784347451fdbf4671ba97018f816041ba2306a
> Author: Mike Snitzer <snitzer@redhat.com>
> Date:   Tue Nov 10 13:41:53 2020 -0500
> 
>     dm: rename multipath path selector source files to have "dm-ps" prefix
> 
> The analysis is as follows:
> 
>  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;
>    1. var_decl: Declaring variable cpu without initializer.
> 
>  48        unsigned int cpu;
>  49        int ret;
>  50
>    2. Condition argc != 1, taking false branch.
> 
>  51        if (argc != 1) {
>  52                *error = "io-affinity ps: invalid number of arguments";
>  53                return -EINVAL;
>  54        }
>  55
> 
>    Uninitialized scalar variable (UNINIT)
>    3. uninit_use_in_call: Using uninitialized value cpu when calling
> __cpu_to_node.
> 
>  56        pi = kzalloc_node(sizeof(*pi), GFP_KERNEL, cpu_to_node(cpu));
>  57        if (!pi) {
>  58                *error = "io-affinity ps: Error allocating path context";
>  59                return -ENOMEM;
>  60        }

Valid report, but it focuses on a follow-on commit that is just noise.
The commit "dm mpath: add IO affinity path selector" is what is in
quesation, see:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-5.11&id=c3d0a31e609e299836fa6ced28cb9ec06b408181

Regardless, Mike Christie, Colin's report has identified a bug.

Please advise on how you'd like to fix ioa_add_path()'s allocation of
'struct path_info'.. pretty sure 'cpu' will default to 0 (on stack)
despite no explicit initialization... so code "works" but does not
do so with a specific cpu allocation affinity.

Mike

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2020-11-11 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 11:45 [dm-devel] dm: rename multipath path selector source files to have "dm-ps" prefix Colin Ian King
2020-11-11 11:45 ` Colin Ian King
2020-11-11 15:24 ` Mike Snitzer [this message]
2020-11-11 16:46   ` [dm-devel] " Mike Christie

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=20201111152436.GA22834@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=colin.king@canonical.com \
    --cc=dm-devel@redhat.com \
    --cc=michael.christie@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.