From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Subject: [PATCH] APEI: pull a signedness check ahead for Coverity's sake
Date: Wed, 08 Jun 2016 05:37:28 -0600 [thread overview]
Message-ID: <57581F9802000078000F2FD6@prv-mh.provo.novell.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
On 64-bit architectures (which is all we care about right now in ACPI
code), the value coming from a __u32 field makes "len" positive anyway,
but since from an abstract pov the tool is right, let's just re-order
things.
Coverity ID: 1204965
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/drivers/acpi/apei/erst.c
+++ b/xen/drivers/acpi/apei/erst.c
@@ -672,9 +672,11 @@ static ssize_t __erst_read(u64 record_id
if (rcd_tmp->record_length > buflen)
return -ENOBUFS;
len = rcd_tmp->record_length;
+ if (len < 0)
+ return -ERANGE;
memcpy(record, rcd_tmp, len);
- return len >= 0 ? len : -ERANGE;
+ return len;
}
/*
[-- Attachment #2: CID1204965.patch --]
[-- Type: text/plain, Size: 723 bytes --]
APEI: pull a signedness check ahead for Coverity's sake
On 64-bit architectures (which is all we care about right now in ACPI
code), the value coming from a __u32 field makes "len" positive anyway,
but since from an abstract pov the tool is right, let's just re-order
things.
Coverity ID: 1204965
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/drivers/acpi/apei/erst.c
+++ b/xen/drivers/acpi/apei/erst.c
@@ -672,9 +672,11 @@ static ssize_t __erst_read(u64 record_id
if (rcd_tmp->record_length > buflen)
return -ENOBUFS;
len = rcd_tmp->record_length;
+ if (len < 0)
+ return -ERANGE;
memcpy(record, rcd_tmp, len);
- return len >= 0 ? len : -ERANGE;
+ return len;
}
/*
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next reply other threads:[~2016-06-08 11:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 11:37 Jan Beulich [this message]
2016-06-09 14:13 ` [PATCH] APEI: pull a signedness check ahead for Coverity's sake Andrew Cooper
2016-06-09 14:24 ` Julien Grall
2016-06-09 15:08 ` Jan Beulich
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=57581F9802000078000F2FD6@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.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 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.