From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-ppc@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Peter Maydell <peter.maydell@linaro.org>,
David Gibson <david@gibson.dropbear.id.au>,
qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>
Subject: [PATCH qemu] ppc/vof: Fix Coverity issues
Date: Tue, 13 Jul 2021 23:46:38 +1000 [thread overview]
Message-ID: <20210713134638.1803316-1-aik@ozlabs.ru> (raw)
This fixes NEGATIVE_RETURNS, OVERRUN issues reported by the Coverity.
This adds a comment about the return parameters number in the VOF hcall.
The reason for such counting is to keep the numbers look the same in
vof_client_handle() and the Linux (an OF client).
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Will this make COverity happy? What is the canonical way of fixing these
uint32_t vs. int? Thanks,
---
hw/ppc/vof.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index 81f65962156c..872f671babbe 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -517,7 +517,7 @@ static uint32_t vof_instance_to_package(Vof *vof, uint32_t ihandle)
static uint32_t vof_package_to_path(const void *fdt, uint32_t phandle,
uint32_t buf, uint32_t len)
{
- uint32_t ret = -1;
+ int ret = -1;
char tmp[VOF_MAX_PATH] = "";
ret = phandle_to_path(fdt, phandle, tmp, sizeof(tmp));
@@ -529,13 +529,13 @@ static uint32_t vof_package_to_path(const void *fdt, uint32_t phandle,
trace_vof_package_to_path(phandle, tmp, ret);
- return ret;
+ return (uint32_t) ret;
}
static uint32_t vof_instance_to_path(void *fdt, Vof *vof, uint32_t ihandle,
uint32_t buf, uint32_t len)
{
- uint32_t ret = -1;
+ int ret = -1;
uint32_t phandle = vof_instance_to_package(vof, ihandle);
char tmp[VOF_MAX_PATH] = "";
@@ -549,7 +549,7 @@ static uint32_t vof_instance_to_path(void *fdt, Vof *vof, uint32_t ihandle,
}
trace_vof_instance_to_path(ihandle, phandle, tmp, ret);
- return ret;
+ return (uint32_t) ret;
}
static uint32_t vof_write(Vof *vof, uint32_t ihandle, uint32_t buf,
@@ -965,11 +965,15 @@ int vof_client_call(MachineState *ms, Vof *vof, void *fdt,
}
nret = be32_to_cpu(args_be.nret);
+ if (nret > ARRAY_SIZE(args_be.args) - nargs) {
+ return -EINVAL;
+ }
ret = vof_client_handle(ms, fdt, vof, service, args, nargs, rets, nret);
if (!nret) {
return 0;
}
+ /* @nrets includes the value which this function returns */
args_be.args[nargs] = cpu_to_be32(ret);
for (i = 1; i < nret; ++i) {
args_be.args[nargs + i] = cpu_to_be32(rets[i - 1]);
--
2.30.2
next reply other threads:[~2021-07-13 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 13:46 Alexey Kardashevskiy [this message]
2021-07-19 3:57 ` [PATCH qemu] ppc/vof: Fix Coverity issues David Gibson
2021-07-19 8:25 ` Alexey Kardashevskiy
2021-07-19 12:07 ` David Gibson
2021-07-19 7:55 ` Greg Kurz
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=20210713134638.1803316-1-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).