From patchwork Wed Jun 8 11:37:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9164349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0094160572 for ; Wed, 8 Jun 2016 11:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4959262AE for ; Wed, 8 Jun 2016 11:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D92F0269A3; Wed, 8 Jun 2016 11:40:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8483C262AE for ; Wed, 8 Jun 2016 11:40:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAbnj-0000Bk-8R; Wed, 08 Jun 2016 11:37:35 +0000 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 Received: from [193.109.254.147] by server-15.bemta-14.messagelabs.com id 29/8A-29877-D7308575; Wed, 08 Jun 2016 11:37:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRWlGSWpSXmKPExsXS6fjDS7eWOSL c4EiYxfctk5kcGD0Of7jCEsAYxZqZl5RfkcCasXDWcbaChfwVB350sjcw9vN2MXJyCAnkSZy5 eIgJxOYVsJO4degwI4gtIWAosW/+KjYQm0VAVWL19FnsIDabgLpE27PtrF2MHBwiAgYS544mg ZjCAp4Sb5ZUgpi8AoISf3cIgxQzAw08dPIF6wRGzlkImVlIMhC2lsTDX7dYIGxtiWULXzODlD MLSEss/8cBYRpK3N5dhaoCxLaRmLfjLMsCRo5VjOrFqUVlqUW65npJRZnpGSW5iZk5uoaGJnq 5qcXFiempOYlJxXrJ+bmbGIHBxQAEOxi/LHE+xCjJwaQkyqvoHh4uxJeUn1KZkVicEV9UmpNa fIhRhoNDSYL3N2NEuJBgUWp6akVaZg4wzGHSEhw8SiK88iBp3uKCxNzizHSI1ClGRSlxXlkmo IQASCKjNA+uDRZblxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMKw4yhSczrwRu+iugxUxAi5 cfCQdZXJKIkJJqYLTi7O+w9/T/5O/xWqOble9cxG4BbuWr6zR+rW55wf+Q2/+FsR/v83/ZXzo tFz7LDblokmdv4NB57Iek1/yQBCUTj6cyNc63djVnLbYXDyzj8n5wu+C/dewZwW9L55Qm3lP8 6c75ZfWMv67XJiwq+OV5X6+f20JGfffTX/XzZAz6Np6fdtiPSYmlOCPRUIu5qDgRAJbqfcmoA gAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1465385850!34325724!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8178 invoked from network); 8 Jun 2016 11:37:32 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Jun 2016 11:37:32 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 08 Jun 2016 05:37:30 -0600 Message-Id: <57581F9802000078000F2FD6@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 08 Jun 2016 05:37:28 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Subject: [Xen-devel] [PATCH] APEI: pull a signedness check ahead for Coverity's sake X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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 --- 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; } /* Reviewed-by: Andrew Cooper --- 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; } /*