From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
"qemu-ppc@nongnu.org list:PowerPC" <qemu-ppc@nongnu.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] spapr: Fix Coverity warning while validating nvdimm options
Date: Wed, 26 Feb 2020 13:27:45 +0100 [thread overview]
Message-ID: <CAAdtpL5gYr9ZRhSdqfhKMVQ41BUUZqYbbFGyMLTPaROfazW8cA@mail.gmail.com> (raw)
In-Reply-To: <158271897341.44994.2741557659975232894.stgit@lep8c.aus.stglabs.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]
Le mer. 26 févr. 2020 13:11, Shivaprasad G Bhat <sbhat@linux.ibm.com> a
écrit :
> Fixes Coverity issue,
> CID 1419883: Error handling issues (CHECKED_RETURN)
> Calling "qemu_uuid_parse" without checking return value
>
> nvdimm_set_uuid() already verifies if the user provided uuid is valid or
> not. So, need to check for the validity during pre-plug validation again.
>
> As this a false positive in this case, assert if not valid to be safe.
>
> Reported-by: Coverity (CID 1419883)
> Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
> ---
> hw/ppc/spapr_nvdimm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c
> index 74eeb8bb74..051727536e 100644
> --- a/hw/ppc/spapr_nvdimm.c
> +++ b/hw/ppc/spapr_nvdimm.c
> @@ -44,7 +44,7 @@ void spapr_nvdimm_validate_opts(NVDIMMDevice *nvdimm,
> uint64_t size,
> }
>
> uuidstr = object_property_get_str(OBJECT(nvdimm), NVDIMM_UUID_PROP,
> NULL);
> - qemu_uuid_parse(uuidstr, &uuid);
> + g_assert(qemu_uuid_parse(uuidstr, &uuid) == 0);
>
From https://developer.gnome.org/glib/stable/glib-Testing.html#g-assert
The macro can be turned off in final releases of code by defining
G_DISABLE_ASSERT when compiling the application, so code must not depend on
any side effects from expr.
This looks like bad pattern example.
g_free(uuidstr);
>
> if (qemu_uuid_is_null(&uuid)) {
>
>
>
[-- Attachment #2: Type: text/html, Size: 3131 bytes --]
next prev parent reply other threads:[~2020-02-26 12:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 12:10 [PATCH] spapr: Fix Coverity warning while validating nvdimm options Shivaprasad G Bhat
2020-02-26 12:27 ` Philippe Mathieu-Daudé [this message]
2020-02-26 12:49 ` Greg Kurz
2020-02-27 12:28 ` Greg Kurz
2020-02-27 13:44 ` Shivaprasad G Bhat
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=CAAdtpL5gYr9ZRhSdqfhKMVQ41BUUZqYbbFGyMLTPaROfazW8cA@mail.gmail.com \
--to=f4bug@amsat.org \
--cc=david@gibson.dropbear.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sbhat@linux.ibm.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 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).