From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] APEI: pull a signedness check ahead for Coverity's sake Date: Wed, 08 Jun 2016 05:37:28 -0600 Message-ID: <57581F9802000078000F2FD6@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part0C3A0E68.0__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAbni-0000Be-Ey for xen-devel@lists.xenproject.org; Wed, 08 Jun 2016 11:37:34 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part0C3A0E68.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- 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 =3D rcd_tmp->record_length; + if (len < 0) + return -ERANGE; memcpy(record, rcd_tmp, len); =20 - return len >=3D 0 ? len : -ERANGE; + return len; } =20 /* --=__Part0C3A0E68.0__= Content-Type: text/plain; name="CID1204965.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="CID1204965.patch" APEI: pull a signedness check ahead for Coverity's sake=0A=0AOn 64-bit = architectures (which is all we care about right now in ACPI=0Acode), the = value coming from a __u32 field makes "len" positive anyway,=0Abut since = from an abstract pov the tool is right, let's just re-order=0Athings.=0A=0A= Coverity ID: 1204965=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/drivers/acpi/apei/erst.c=0A+++ b/xen/drivers/acpi/apei/erst.c= =0A@@ -672,9 +672,11 @@ static ssize_t __erst_read(u64 record_id=0A if = (rcd_tmp->record_length > buflen)=0A return -ENOBUFS;=0A = len =3D rcd_tmp->record_length;=0A+ if (len < 0)=0A+ = return -ERANGE;=0A memcpy(record, rcd_tmp, len);=0A =0A- return len = >=3D 0 ? len : -ERANGE;=0A+ return len;=0A }=0A =0A /*=0A --=__Part0C3A0E68.0__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part0C3A0E68.0__=--