Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5599918rwn; Mon, 12 Sep 2022 11:26:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nVVjxQSEBqvS6I5CmUCS7HYp17PNeT1EjIizKDQ4n6+qTTgbEIzZzuIVgKAb3UT50SV2K X-Received: by 2002:a05:6402:1f89:b0:44e:798b:75c6 with SMTP id c9-20020a0564021f8900b0044e798b75c6mr22984672edc.407.1663007199178; Mon, 12 Sep 2022 11:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663007199; cv=none; d=google.com; s=arc-20160816; b=Ht6kZYO1P8g0ygkPorJHYPN7TZS8RIIMnrEmBZkKBc3UPKbqvO/RBxI6N+vtQ5zxMj g5UG+NQkOc6DvARPgg5V5B3aR7Vz8hX9qidUVq/hjHHRsUSdKhESPmMOJG9jmZ2CpAMu PajO7DKkk/ykKSB33rdQ/1ieDKYuNwEaJIcN18rR0G32/0aiasxJisLBAB4uY5zp64Sh TQoMhDrvkPOuuFB2CkR6jHTzriC25X3q8KkyYHZbTvQlPZSgzfTj744Cl+JBVnL0ZDMQ iq8rfBek2T7RayA4utCPXa+NXb72wiXmpWQK4Co67riUY2QLJbLa+DCxViO8hYj5UgXF Sawg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=YPKBe9B3XbC8RUfPOGArlb9dr+0GqBtfH24k5Otusrk=; b=UEW0Oiul9S+ATR8MOpppvi9rWYpaLZ0uslCsteBWEbSJ+dZQqIQ2fKKVBzRaGen9r7 aK2E95MeyiNeQAZurnxeFLOmVceVP+UoE5tMQ2N903J+sPPJ6lCOtTtmRcHOACKUsGzw hK3uWk1Ykqvm7kKgC43Um2Ux+h1QgOjuIvFxUwVlZSr/lCQX6hD4Gopa5+SpfuFdZFdC uGJDkAXG10AIphLceayZbn3fmq1pDVqr6H7MJzvn0XpMz4l+RULfCVg8HI6SDqFV+20r LVLZ0azFlB/SFjRSq/DeB6A4eqefgwZIvxBSpMuByA/U6v7vw53CwOBwm65ed1buVwfh YUCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YacZ7pCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a0564020e0400b0044e8e0dc87fsi7047969edh.362.2022.09.12.11.26.13; Mon, 12 Sep 2022 11:26:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YacZ7pCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbiILSOt (ORCPT + 99 others); Mon, 12 Sep 2022 14:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiILSOr (ORCPT ); Mon, 12 Sep 2022 14:14:47 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B2D76271; Mon, 12 Sep 2022 11:14:46 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id u28so3720155qku.2; Mon, 12 Sep 2022 11:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=YPKBe9B3XbC8RUfPOGArlb9dr+0GqBtfH24k5Otusrk=; b=YacZ7pCFkqrvZCQtCIGbDt2MYK3i+sd3xi1qTDTf1RqY9UYfccxhJQwuo4vjytaVrV LvCX0WexjcADJKv1qBmMPN/ovyIa+1a5ZV13RyU452y2Rt7Jh8lM24X5lmw701OWu1hU P21rekXqi5mPPJWZ1Emm/j4CYCwUSVXdIzHVELNE4vT/TUrKmW9Hvxu69GESQ2rK3jsO eaMp4Yo8i5cPA1GX+OFYToufY0+7aWTdgpnr0ALI3B+vUg7jgXHVzB1Zf81gry1D8YPH MJ9NK5UXiSgdO7gj9jvgTPBxwTIHMZbOXFP68b6QZhK7o3hDKKUNptDkh2Vjcxrpo5Vn 5WAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=YPKBe9B3XbC8RUfPOGArlb9dr+0GqBtfH24k5Otusrk=; b=zGTfv8dwjR//+61/3e4Zf/99Q+ZLuFGSlBhmGg4VtBaNpO/u+moHZGarIoGzwPbiEZ qbgptA8XiYdInh5nV6tc4om424rr2a61CjJes51hd3reNIATMMfYD+S6XyiFwFflpk3g O1JT2v2d0wyiKVEJGX6x23CBCfifqrr7FoHjr1OGTxzaLHtairaBlsloEjHO/09u5Lc4 Dy3CR+5ACo74wE6FE5gxjIJ5mqzAp945KtVGsDQZnsTc3v96ciQe9Ek+Sr+gS8AzcsIb /Vf9/2Z7tDZzFA12GarAJ7cN3HH7m+A+ZXwW5hBEVDLb+ZFTs6aFjm8+W2ypw9o8GzQM JWVA== X-Gm-Message-State: ACgBeo0ICPVOkd5shmFUptuKBoECMWyYCml9Rhnl8o9m6NPU+pON8TNJ JDkmFf71+WFXCtrQEq4SX3o= X-Received: by 2002:a05:620a:d8c:b0:6a7:91a4:2669 with SMTP id q12-20020a05620a0d8c00b006a791a42669mr20165762qkl.269.1663006485451; Mon, 12 Sep 2022 11:14:45 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id d5-20020a05622a15c500b0035bb6298526sm2342497qty.17.2022.09.12.11.14.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Sep 2022 11:14:44 -0700 (PDT) Message-ID: <2380c655-a6ba-7cdb-06d1-9c7856ff6cce@gmail.com> Date: Mon, 12 Sep 2022 11:14:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] net: broadcom: bcm4908enet: add platform_get_irq_byname error checking Content-Language: en-US To: Dan Carpenter , Yu Zhe Cc: rafal@milecki.pl, bcm-kernel-feedback-list@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, liqiong@nfschina.com References: <20220909062545.16696-1-yuzhe@nfschina.com> From: Florian Fainelli In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/12/22 04:29, Dan Carpenter wrote: > On Fri, Sep 09, 2022 at 02:25:45PM +0800, Yu Zhe wrote: >> The platform_get_irq_byname() function returns negative error codes on error, >> check it. >> >> Signed-off-by: Yu Zhe >> --- >> drivers/net/ethernet/broadcom/bcm4908_enet.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c >> index c131d8118489..d985056db6c2 100644 >> --- a/drivers/net/ethernet/broadcom/bcm4908_enet.c >> +++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c >> @@ -705,6 +705,8 @@ static int bcm4908_enet_probe(struct platform_device *pdev) >> return netdev->irq; >> >> enet->irq_tx = platform_get_irq_byname(pdev, "tx"); >> + if (enet->irq_tx < 0) >> + return enet->irq_tx; >> > > If you read the driver, then you will see that this is deliberate. > Search for irq_tx and read the comments. I'm not a subsystem expert so > I don't know if this an ideal way to write the code, but it's done > deliberately so please don't change it unless you can test it. Yup, the transmit interrupt is deemed optional, or at least was up to some point during the driver development. There is however a worthy bug you could fix: static int bcm4908_enet_stop(struct net_device *netdev) { struct bcm4908_enet *enet = netdev_priv(netdev); struct bcm4908_enet_dma_ring *tx_ring = &enet->tx_ring; struct bcm4908_enet_dma_ring *rx_ring = &enet->rx_ring; netif_stop_queue(netdev); netif_carrier_off(netdev); napi_disable(&rx_ring->napi); napi_disable(&tx_ring->napi); bcm4908_enet_dma_rx_ring_disable(enet, &enet->rx_ring); bcm4908_enet_dma_tx_ring_disable(enet, &enet->tx_ring); bcm4908_enet_dma_uninit(enet); free_irq(enet->irq_tx, enet); We might attempt to free an invalid interrupt here ^^ free_irq(enet->netdev->irq, enet); return 0; -- Florian