From patchwork Tue Apr 23 16:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13640333 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F0688C4345F for ; Tue, 23 Apr 2024 16:15:46 +0000 (UTC) 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:Subject:Cc:To: From:Date: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=SM0L4H3Gqq8pUMACi6EjqdHoxCLFquaJdeWV+Wkao+g=; b=Z/nkFiuExmxoO4 qEOoIw8boYL+rG1Iw7Guit1WlfrLAoyEUXnZaft8jWjWLQWfAgy1O95U55T12FawfYlhT2hKDN0vP nHifsmc3z4/eRSbFnPHTZvEzhlMelU6Cqji5P2nwaEEpHKX2V/b5c/DMfiCHRXQRVULhEL4PNW6gI Sh0NQRPp0Nv3Cv5nW41uY4r4SAgIyP6xIfqiXMei+3F0iNWT5lu+46LknRpQSNZPD/4yAiM8thdJe rdUjxFXNpwK9pqXBGY1i8c1pfRm5SOmkoUA3Fl+6/u4Diq00+lqlJ1BPrljHXtOC6hK3N+DdWfhow 0RQFZ34wZkAH2NPgXDOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzInu-00000000gy7-1FIy; Tue, 23 Apr 2024 16:15:34 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzInq-00000000gv9-3EKt for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 16:15:33 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41a7ae25d53so15736145e9.1 for ; Tue, 23 Apr 2024 09:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713888927; x=1714493727; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=aGBFoVzf1KRLH5Odstgg3LFS1yioFZbFNqqfkb5RbTI=; b=IipVMLUrDccKWS9mVXZO+0bViU/KdSkPgfaj+kItZKldxLoYmjNyG8QlmZsfxtqT6S 7NlNRUXSVJnCOpBDMsECkv11Gek+cquDZG9yRDtLOALOXF/FlZEDUZYpqCUSkIHAEJ7S HShxBgxFXfyeBIkK/Wn6Ilm1KeJmf10yejy6SU9avYiKtyQlA7vziaV2qQz1VJAdNf4G dkOypAF0yvNyIYMPfzt7SNBy5wiixkxDD42po4uFFnjqeSp4hZkAr3pnZdi1QV9COlPs JVdPl2nWbIafrvLpjoQy+2Kq+ASlZVnY1OBHUA2SNIfO/DBA6nOFN+bBexWggvZtwJv9 ksiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713888927; x=1714493727; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aGBFoVzf1KRLH5Odstgg3LFS1yioFZbFNqqfkb5RbTI=; b=Ivn3sdMGDG9egsFgRhwVdClnTSpTXYXRuF5m81mwfSK1NTbky6W2ycZMf8tuzfm1JP ALLVEJxvg8sdGltvNdjzN4/diuiGOKUUwndbuNCxjdpJZS5DB6uBkufv1BuUKtPYDs1E S3pbfebgVzobQje1ODrD9l9S9xANh7kcKa2t4Y9VUfJ5PgdDINuC5d/8QKt0SSCIb5XN cMGbEVxHNpw0cZplWFbjAaS4uabVqY8TviCVya0rff5qKqk3Q6e8XDXtDG+yscBRslBH XOz1i3DY8VEnaCksknvlqGuFRBt/K0XBEf48uX4e75L4VN/GFIX5HJp4IUQCr/IzffF3 0jEw== X-Forwarded-Encrypted: i=1; AJvYcCV5tpz9y8dL7+bKMzzYYed+kn2W2Ko1tXiE5avLgl/VE+ui5YJCmUpi2BuOqJmX3OLCuRZ6m8LH9ure0eWQ5oiucvq0XCxR5z0NqBBHJ662lTrjZHY= X-Gm-Message-State: AOJu0YweOdXDx6hhYfgsd7gj8J5n7Bxt5Il4C3A2l6r9/C0++4ErGJS2 k+PgGhIMewo/RHOWUyyOXrpqpFx2eUVAOLREdSu6MWY+6mONPf3GBtiDN8C0V7E= X-Google-Smtp-Source: AGHT+IE0GJcrYh2uj7iVpjzuFMPPNn/sVzz8Si2u+zGBXWE4Gnyuc9CrWVmaNdxpA3mmLcqKuzOVcA== X-Received: by 2002:a05:600c:474a:b0:41a:a298:2369 with SMTP id w10-20020a05600c474a00b0041aa2982369mr1951245wmo.11.1713888927099; Tue, 23 Apr 2024 09:15:27 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id t13-20020a05600c198d00b00417da22df18sm24349591wmq.9.2024.04.23.09.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 09:15:26 -0700 (PDT) Date: Tue, 23 Apr 2024 19:15:22 +0300 From: Dan Carpenter To: Roger Quadros Cc: MD Danish Anwar , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Jan Kiszka , Diogo Ivo , Rob Herring , Grygorii Strashko , Vignesh Raghavendra , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_rx_chns() Message-ID: <05282415-e7f4-42f3-99f8-32fde8f30936@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_091530_951590_6311726B X-CRM114-Status: GOOD ( 14.67 ) 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 The rx_chn->irq[] array is unsigned int but it should be signed for the error handling to work. Also if k3_udma_glue_rx_get_irq() returns zero then we should return -ENXIO instead of success. Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver") Signed-off-by: Dan Carpenter Reviewed-by: Roger Quadros Reviewed-by: MD Danish Anwar --- I had previously fixed the issues with the tx_chns() version of this but I didn't realize there was an rx version. These functions got moved around in net-next so that's why I noticed this bug... Moving the code around makes applying this to net-next kind of pain. drivers/net/ethernet/ti/icssg/icssg_prueth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index cf7b73f8f450..b69af69a1ccd 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -421,12 +421,14 @@ static int prueth_init_rx_chns(struct prueth_emac *emac, if (!i) fdqring_id = k3_udma_glue_rx_flow_get_fdq_id(rx_chn->rx_chn, i); - rx_chn->irq[i] = k3_udma_glue_rx_get_irq(rx_chn->rx_chn, i); - if (rx_chn->irq[i] <= 0) { - ret = rx_chn->irq[i]; + ret = k3_udma_glue_rx_get_irq(rx_chn->rx_chn, i); + if (ret <= 0) { + if (!ret) + ret = -ENXIO; netdev_err(ndev, "Failed to get rx dma irq"); goto fail; } + rx_chn->irq[i] = ret; } return 0;