From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: John Stoffel <john@stoffel.org>
Cc: neilb@suse.de, artur.paszkiewicz@intel.com, linux-raid@vger.kernel.org
Subject: Re: [PATCH 4/5] IncrementalScan(): Make sure 'st' is valid before dereferencing it
Date: Wed, 25 Feb 2015 10:37:38 -0500 [thread overview]
Message-ID: <wrfjioeq2e9p.fsf@redhat.com> (raw)
In-Reply-To: <21741.58242.604155.228473@quad.stoffel.home> (John Stoffel's message of "Wed, 25 Feb 2015 10:00:18 -0500")
"John Stoffel" <john@stoffel.org> writes:
>>>>>> "Jes" == Jes Sorensen <Jes.Sorensen@redhat.com> writes:
>
> Jes> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> Jes> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> Jes> ---
> Jes> Incremental.c | 2 +-
> Jes> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Jes> diff --git a/Incremental.c b/Incremental.c
> Jes> index 87d9114..33c0d7f 100644
> Jes> --- a/Incremental.c
> Jes> +++ b/Incremental.c
> Jes> @@ -1354,7 +1354,7 @@ restart:
> Jes> if (st && st->ss->load_container)
> Jes> ret = st->ss->load_container(st, mdfd, NULL);
> Jes> close(mdfd);
> Jes> - if (!ret && st->ss->container_content) {
> Jes> + if (!ret && st && st->ss->container_content) {
> Jes> if (map_lock(&map))
> Jes> pr_err("failed to get exclusive lock on mapfile\n");
> Jes> ret = Incremental_container(st, me->path, c, only);
> Jes> --
> Jes> 2.1.0
>
> Forgive my stupidity, but how does this really help anything? You
> already did the check above for a valid 'st', and now you're just
> repeating it. Maybe if needs to be more of:
>
> if (st) {
> if (st->ss->load_container)
> ret = st->ss->load_container(st,mdfd, NULL);
> close(mdfd);
> if (!ret && st->ss->container_content) {
> .....
> }
> }
>
> but maybe I'm just missing something here.
Please look more carefully - the checks above are in place so 'st' is
only dereferenced if 'st is valid. The code does not bail out if
st = NULL.
Your example results in mdfd not getting closed if st == NULL.
Jes
next prev parent reply other threads:[~2015-02-25 15:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 21:00 [PATCH 0/5] Fix issues reported by covscan and newer GCC Jes.Sorensen
2015-02-24 21:00 ` [PATCH 1/5] Grow.c: Fix classic readlink() buffer overflow Jes.Sorensen
2015-02-24 21:00 ` [PATCH 2/5] Check return of stat() to avoid covscan complaining Jes.Sorensen
2015-02-24 21:12 ` NeilBrown
2015-02-24 21:56 ` Jes Sorensen
2015-02-24 22:03 ` NeilBrown
2015-02-25 0:13 ` Jes Sorensen
2015-02-24 21:00 ` [PATCH 3/5] add_orom(): Compare content of struct imsm_orom rather than pointers to it Jes.Sorensen
2015-02-25 10:51 ` Artur Paszkiewicz
2015-02-25 12:29 ` Jes Sorensen
2015-02-25 16:32 ` Artur Paszkiewicz
2015-02-25 17:15 ` Jes Sorensen
2015-02-27 13:39 ` Artur Paszkiewicz
2015-02-27 20:51 ` Jes Sorensen
2015-03-04 4:58 ` NeilBrown
2015-02-24 21:00 ` [PATCH 4/5] IncrementalScan(): Make sure 'st' is valid before dereferencing it Jes.Sorensen
2015-02-25 15:00 ` John Stoffel
2015-02-25 15:37 ` Jes Sorensen [this message]
2015-02-25 15:42 ` John Stoffel
2015-02-24 21:00 ` [PATCH 5/5] write_super_imsm_spares(): C statements are terminated by ; Jes.Sorensen
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=wrfjioeq2e9p.fsf@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=artur.paszkiewicz@intel.com \
--cc=john@stoffel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).