From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31797C433EF for ; Tue, 19 Oct 2021 12:31:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E610B61378 for ; Tue, 19 Oct 2021 12:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E610B61378 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=OV1jJj+RujnD11kSn0sQk+kQlTRaEaiTPmQRgjDzNP4=; b=MyjNMCvSxTZuJd 2R9YxYL+JI9IRV9TZu1k4Cpo+BDwbAQkLwdAO8UnZzrV3gLYMBm+01H9CfAuPOEaOZ7MED/zR+3jW xGfytJsGv0lo4/Lmo4WH9ZYCUBdk7j1ptXz4965ei2zp2A9yuCG3AzUWrlWRXxWxION7QV4Z4ICg5 NxW7sLLQ25D6AVMZIjOlBA+oWlwTr9RYGbcvaocnbEaimaKab4NwnCiOZ2JCcjh7rBrU+tA1ibhc/ G8+xK74c878k3uQ8Yz1tX5IgmT+u36h+22s0K8jYcvGhJdhz0XI7I7ERKYnNaVu0LSycH8jdbUD8A Cbmz8gJjPrqZJILgLc9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcoFS-001C9g-Bu; Tue, 19 Oct 2021 12:29:42 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mco5w-0018Jd-Iw for linux-arm-kernel@lists.infradead.org; Tue, 19 Oct 2021 12:19:54 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1116C3FFDC for ; Tue, 19 Oct 2021 12:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634645991; bh=S5hSs0IsYHo4czoU+ZSwS65AB7r69uVnogvCkeb+UaY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=goFZpP5KNea5gq70vpwYi8/RGdpk30/9m03MJcs5zm142C/kW5F7riQDAM0m2fcrr L9pb3H2KCGutPAH5Gu5tT7L3rIjxHzDx0KXcoXlnA6vcykDZzgzb4GCWzKeDHo/qoU 4y70BI2Pkf5XfEtPSGYZvRoFyG6SvmInXKtW6PCVWizh+Hr4lanB0T6ssuhQob8M0I GvWbvBzAm+WqB4UH2Py81kZn6wcSkKKNgxGoqwRIyEb5sNSoxRKVKwPNPbXoIoDR4E B6nZByLsDTEr9aiBcfNgVQ4AFaKGm08YSLHY0ADzrKva20d9I/pT40dfmNoFoGee/k RDpF6wWU7IBvA== Received: by mail-pj1-f71.google.com with SMTP id ob9-20020a17090b390900b001a0fd49248fso1476168pjb.5 for ; Tue, 19 Oct 2021 05:19:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S5hSs0IsYHo4czoU+ZSwS65AB7r69uVnogvCkeb+UaY=; b=yDCRRoDkC2zqI6IvSPDr8pGzxsT47NeJVq1oyqZ2HtvKZfkeThhZawpYfzoocS1NSV y0CC089YfKwcvoZ3Mix/xjkcAnFktqV2HiQBUrZRr5tsZktJUWthlmb0Ko5xlCsg4vQU I9UPDab9G7JzHCJeNL0U+kkGoeYPqAgVSzb+hWno8ZK7Xa7QBRBKnm/hY2gGbw9GqZcI MkWSmPo8rFbd2AW/mm7xrhLkkUcH1Qp9aWO7RRerxorKOGvuqFPbxk3FRszLfqyPr8zy EuR8bj7xm52trEU67Qh3upmQc0Koc47clTiNiqXPemSAWR8UjcdtZ5SFYJb68EPL3/CJ tmNA== X-Gm-Message-State: AOAM53152xtGgLLRkTqpwMDl599BgdWn+hTTBwJQTebiU6rbxj/7jL6i TFKJ4YlQsaeBfExEWsLYMF9xzj4lLmA+uXOT1dpaV6qmST8iLnUuskRAVaG/eTc4tpkw/XhcWtu j0TMM5GsHQKF+dN1Euuq5QgNx3hq5Eg/VTzMASZ5zGOM1oAdzfJpj X-Received: by 2002:a63:1a1b:: with SMTP id a27mr28220396pga.220.1634645989569; Tue, 19 Oct 2021 05:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbyPSE4NlHm4yFcKK7AkscCZM/c58AVrYx67InnYieO9ip6aITa2c/Inpm/1ZU1/nozfudIA== X-Received: by 2002:a63:1a1b:: with SMTP id a27mr28220375pga.220.1634645989228; Tue, 19 Oct 2021 05:19:49 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id d71sm12152571pga.67.2021.10.19.05.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 05:19:48 -0700 (PDT) From: Tim Gardner To: netdev@vger.kernel.org Cc: Tim Gardner , Ioana Ciornei , Roy Pledge , Li Yang , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2][net-next] soc: fsl: dpio: Unsigned compared against 0 in qbman_swp_set_irq_coalescing() Date: Tue, 19 Oct 2021 06:19:25 -0600 Message-Id: <20211019121925.8910-1-tim.gardner@canonical.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_051952_932686_2F8BDE7D X-CRM114-Status: GOOD ( 16.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Coverity complains of unsigned compare against 0. There are 2 cases in this function: 1821 itp = (irq_holdoff * 1000) / p->desc->qman_256_cycles_per_ns; CID 121131 (#1 of 1): Unsigned compared against 0 (NO_EFFECT) unsigned_compare: This less-than-zero comparison of an unsigned value is never true. itp < 0U. 1822 if (itp < 0 || itp > 4096) { 1823 max_holdoff = (p->desc->qman_256_cycles_per_ns * 4096) / 1000; 1824 pr_err("irq_holdoff must be between 0..%dus\n", max_holdoff); 1825 return -EINVAL; 1826 } 1827 unsigned_compare: This less-than-zero comparison of an unsigned value is never true. irq_threshold < 0U. 1828 if (irq_threshold >= p->dqrr.dqrr_size || irq_threshold < 0) { 1829 pr_err("irq_threshold must be between 0..%d\n", 1830 p->dqrr.dqrr_size - 1); 1831 return -EINVAL; 1832 } Fix this by removing the comparisons altogether as they are incorrect. Zero is a possible value in either case. Also fix a minor comment typo and update the 2 pr_err() calls to use %u formatting as well as be more precise regarding the exact error. Fixes: ed1d2143fee5 ("soc: fsl: dpio: add support for irq coalescing per software portal") Cc: Ioana Ciornei Cc: Roy Pledge Cc: Li Yang Cc: linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org Cc: netdev@vger.kernel.org Signed-off-by: Tim Gardner --- v1 - check itp and irq_threshold for 0. v2 - drop the checks for comparison to 0. Update pr_err() calls with precise language about the error. --- drivers/soc/fsl/dpio/qbman-portal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c index d3c58df6240d..3474bf5f88d5 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.c +++ b/drivers/soc/fsl/dpio/qbman-portal.c @@ -1816,18 +1816,17 @@ int qbman_swp_set_irq_coalescing(struct qbman_swp *p, u32 irq_threshold, u32 itp, max_holdoff; /* Convert irq_holdoff value from usecs to 256 QBMAN clock cycles - * increments. This depends to the QBMAN internal frequency. + * increments. This depends on the QBMAN internal frequency. */ itp = (irq_holdoff * 1000) / p->desc->qman_256_cycles_per_ns; - if (itp < 0 || itp > 4096) { + if (itp > 4096) { max_holdoff = (p->desc->qman_256_cycles_per_ns * 4096) / 1000; - pr_err("irq_holdoff must be between 0..%dus\n", max_holdoff); + pr_err("irq_holdoff must be <= %uus\n", max_holdoff); return -EINVAL; } - if (irq_threshold >= p->dqrr.dqrr_size || irq_threshold < 0) { - pr_err("irq_threshold must be between 0..%d\n", - p->dqrr.dqrr_size - 1); + if (irq_threshold >= p->dqrr.dqrr_size) { + pr_err("irq_threshold must be < %u\n", p->dqrr.dqrr_size - 1); return -EINVAL; } -- 2.33.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel