Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4701868imm; Wed, 30 May 2018 10:15:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7SAiEiwb01z8l/XFx+ze7qXi9LiIEJNyd3iCkNEXtAEBo3QSfTxT0gFr5siof2F/KrP62 X-Received: by 2002:a65:5244:: with SMTP id q4-v6mr2839673pgp.201.1527700514450; Wed, 30 May 2018 10:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527700514; cv=none; d=google.com; s=arc-20160816; b=xchKRV+SodW89j3qwfw18j+nakbIICGssE47fE9Zukb182IphWNP8CfwuEx3Wv4T3O pMONDuZaLyRcZNKaJe4t26bTRMCUxer+bMFV7bXuOz73hCoCvZDJkJl5k+XTLrEswksX HFH53BdDwDXQo9OwmiGdeMuy/nlZADBehOxcwpGdNxV2Rs08hSHXMEia+dKIH2IziZjC DZ12e9OOEgygt0f9Tkc8+c2bYckZpJQ/ZQPqdxJ7bfv54x3Ta4pSwDg+V7XIpVANgPi4 mbOpw+zl3axvxT4OpL2FWggkghtYibpnlyNuH5olmWp0X0j2UUpBE/YVFIVmRtD6sINj +38Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=IuYBZRZNEQkEqViiMXnKE0suk9lNs9MPvvO1DKU/Zc0=; b=YteXptMHW3r+86KCt4e/P0dp/TQopSOQQIybl1UIuH/OBfrKPCYhLnTJlsR8LEtV8k euCfBKltI+6uy1/1+URytpGY7OG6BG2VzMpCBAHJik/QwQ87Z4wgtcBWVUvyQOkvXJKY ZVp7TX37aH7IWNJ4qIo+ccIoxHrl/8m+KvmKVPCuslANhggFbj6i7qg6XNltGqgr8FNf R86SWTEWaCwREqBBaXrgiKEMLEs+3bs/EfJF4TVWxIm7/5LbIHSQfne4TrkdscPVF16a B5GMH8Bu8r3SGvdg7iAAs9nYBCx/VX1ATVlm2rCKtUyQFA0XW1NbusYumazAz4pVmDKW s5YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si26355376plo.130.2018.05.30.10.14.59; Wed, 30 May 2018 10:15:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753619AbeE3ROc (ORCPT + 99 others); Wed, 30 May 2018 13:14:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:40536 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752982AbeE3ROb (ORCPT ); Wed, 30 May 2018 13:14:31 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fO4g9-0001oI-Rk; Wed, 30 May 2018 17:14:29 +0000 From: Colin King To: Jassi Brar , Al Stone Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] mailbox: PCC: check for negative count for parse failure checking Date: Wed, 30 May 2018 18:14:29 +0100 Message-Id: <20180530171429.3172-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The function acpi_table_parse_enties_array can potentially return a negative value if parsing fails. Currently the check on the return is not checking for errors, so fix this by adding a -ve check too. Detected by CoverityScan, CID#1469477 ("Improper use of negative value") Fixes: 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT") Signed-off-by: Colin Ian King --- drivers/mailbox/pcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index fc3c237daef2..87d67922020d 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -461,7 +461,7 @@ static int __init acpi_pcc_probe(void) count = acpi_table_parse_entries_array(ACPI_SIG_PCCT, sizeof(struct acpi_table_pcct), proc, ACPI_PCCT_TYPE_RESERVED, MAX_PCC_SUBSPACES); - if (count == 0 || count > MAX_PCC_SUBSPACES) { + if (count <= 0 || count > MAX_PCC_SUBSPACES) { pr_warn("Invalid PCCT: %d PCC subspaces\n", count); return -EINVAL; } -- 2.17.0