From patchwork Mon Oct 18 16:05:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 12567369 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 66116C433F5 for ; Mon, 18 Oct 2021 16:07:29 +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 3355761002 for ; Mon, 18 Oct 2021 16:07:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3355761002 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=RmulU+FOqJYLSQCrH45GWFYLIdnGtLZBU9lWcQr7sL8=; b=kSRew2seFKjuVp wxBY3QOsXvgvly+CVg1zYvuktoTGsILkeMs+SeTTSyifnkZQfhI3wyH0c3QSwfbmjpFGv9xS7yFc+ qy+jCZU9tDvcduPuBhgKWarG4298xwqk1nNhHNNIa6ZYgLLck6zWT9bnwhqghcK8U6q9hMpv3KVBI r3vbW7+zeKBDmJ7nvWTbY4M7eULq7WO41Y1GdvCKhcCRCyKtvKs72KK5qSA/4gcC0xP1X+RfDTHky +hFhV1whi/vL7OTo8LTECSYtTUXse7zmZa/WiNLVh3lONMHtNmlINdUGZzuhi61sbCVXBc9jI1DIb yQhrgBdft/9383V66Ftw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcV9P-00GSg4-VW; Mon, 18 Oct 2021 16:06:12 +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 1mcV9M-00GSeS-RN for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 16:06:10 +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 E917B4074C for ; Mon, 18 Oct 2021 16:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634573160; bh=UwuVR/x7VT/cOQTFcqIu0KjQRbfwdcmSL/xYEKrPIRE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oNLLaoyFkg/uxBxbAlTY9JTnr5BH4rPJIkiPiOGwQ9w2Mj5k5AiBoXEQTMEwHfjAX x9PURYbg8m2N+Rtukubnt0sUMwHTEI7MUzwvTfX0hNBq4OVKNNec8rAdFhRuUPqMXF AypWzIlyg+OMFKHqvATAQ4wfFXqRZUQe7uGvMb6Mfx8elUk3SmgojsDkiYX+XjHllz u0U8yCjVpUkmGy6KQpJHkOLupjSqRR/Tvr7YFVtEHHGXDbgy/OZbH9Hq5qLWuSIqa/ /gEKtcIvP/2Jd+umObUIEiNcadMbWy6ZFqzeJNGOg00QrfhtC2sQOuaXV0lcbYCAP0 PleBhauNvHv8g== Received: by mail-pj1-f71.google.com with SMTP id a6-20020a17090aa50600b001a0a81b8664so12116127pjq.6 for ; Mon, 18 Oct 2021 09:06:00 -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=UwuVR/x7VT/cOQTFcqIu0KjQRbfwdcmSL/xYEKrPIRE=; b=Nc8f3PuOAPgc5UUX4hkxpPRRHS4N8hXwuL9ZgGsx7Qx9pEmYkFXGau2w4vfQAmRP// ImkTGig2Fs5QMYeDrzr+qZcTkEwqYDj7+JdiHSjYDTynXlvJhtzmg5n8iTSR87KtMsbv t1DtUimuQ8hPbov23g3AnmRfOkon8sLu8/L19H+N2O8yxjnmIAPNDFri11iwCQE80myw OhgClzRa6yP6W5A+ZMCIGSzFPSpRlVwhLmxsZUkdnvdvT1smI2Jwtivu3a6jxPJ7Hk2l 1b+r9OcktzfKSzn8LWyr5eaDlyqkLP3zzLX3ycO2VxKOUpCYHlS4aGwnk/rLkEIxNNEJ HAWw== X-Gm-Message-State: AOAM5305IGZg1nzMMIKvXqM8RY6GUyrIMa/bOA2VNYj3z/9h8gNopSLQ M32OukrezKldam4GnxzBsmZYbGL+9Z6TIS/vD2r8L6ry1M9u+sQvFO8jxUs69Fjpg1FyxPKK9Ez N6aX83diKDQhZisBrTKzHIWvGz9kONibgjBvb0br2ATJKhw84ljl+ X-Received: by 2002:a63:f356:: with SMTP id t22mr24443627pgj.18.1634573158442; Mon, 18 Oct 2021 09:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTWyH9GbLkYIHLYPV5b2YP7Ek0Zcm/M4vmWJOVn1YIdz3V4X13i+DMfc/AS49ZtXTFcacYmQ== X-Received: by 2002:a63:f356:: with SMTP id t22mr24443603pgj.18.1634573158224; Mon, 18 Oct 2021 09:05:58 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id u74sm13131500pfc.87.2021.10.18.09.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 09:05:57 -0700 (PDT) From: Tim Gardner To: linux-arm-kernel@lists.infradead.org Cc: tim.gardner@canonical.com, Roy Pledge , Li Yang , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH][linux-next] soc: fsl: dpio: Unsigned compared against 0 in qbman_swp_set_irq_coalescing() Date: Mon, 18 Oct 2021 10:05:41 -0600 Message-Id: <20211018160541.13512-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-20211018_090609_045462_3361579A X-CRM114-Status: GOOD ( 16.56 ) 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: , 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 checking for 0. Also fix a minor comment typo. Fixes ed1d2143fee53755ec601eb4d48a337a93933f71 ("soc: fsl: dpio: add support for irq coalescing per software portal") 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 Signed-off-by: Tim Gardner --- I'm not 100% sure this is the right way to fix the warning, but according to the pr_err() comments these values should never be 0. --- drivers/soc/fsl/dpio/qbman-portal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c index d3c58df6240d..b768a14bb271 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.c +++ b/drivers/soc/fsl/dpio/qbman-portal.c @@ -1816,16 +1816,16 @@ 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 || 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); return -EINVAL; } - if (irq_threshold >= p->dqrr.dqrr_size || irq_threshold < 0) { + if (irq_threshold >= p->dqrr.dqrr_size || !irq_threshold) { pr_err("irq_threshold must be between 0..%d\n", p->dqrr.dqrr_size - 1); return -EINVAL;