Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4543868pxu; Mon, 21 Dec 2020 15:44:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXwYXdWMZNuETmOFzzHmvAcWCADuwf1W5Qcg2evSRfgxsE32o+HfbIAzGuqQUYg6NK6Lf2 X-Received: by 2002:a17:906:391b:: with SMTP id f27mr17056271eje.195.1608594251393; Mon, 21 Dec 2020 15:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608594251; cv=none; d=google.com; s=arc-20160816; b=ZlL/LnBpWF2J+gSjnyor5+SJiwXJKsmhScA5HOr7i4NF4/BmWOPP3fx7AwOtzdMfvW 8ke8isNyMkwRVOXMdgkW6Bwr7x67b9yNvpdZ/78pC0VIa1vzDRa91iDI6P5kMiTDvpu+ WbKuBIhXE4m4v6pLpQZvz3ISpnWhEpmVOXJZaIcOscq0I6LoiPuxFDAYBA7cZ/plTd56 e9qWfxt6bmXLhP3QvZNoq/VfSPk2PMgJKSaM5v5PjWeIQkvaugqlp6XH1mF/sOGhp6WL 50HrIeJ6+n2LMxSNGAeQtKKPpNwLbE7gfX5qI9oCIvnaGBuQOmrgDehmTzF61COv29Cv lSkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:date:message-id:from:references:cc:to :subject:dkim-signature; bh=+SpruTXWYI7kkzwg63Wix/B+XVjogO4KHpq9u4eVk54=; b=F0oDFG8oI6HPIeNMtIqGHH0XKq9KXq1uDkuHhkMydytsjRngUQveyvrBZkuO33Ppx/ bL+Hk7ZYIoY2o74NcyU1OKckji5DV2W8zwPub9Z+Aiiz3hA4vpJEQdBPiZUwjfSdDfsb wpdYi6Awpz8HkXBkg9WunGE3wzl2h5GAiNOarxE/QqDVzy8bGf6mbbTXNIUSvvmmhZTm tLNJ2Avou3ZkP1TYtgDN5aUwJ8Wll0b6/6at/pnKEyeqXXQV/PjNeo2DDRwCreJelGw1 jH+TBiY8e9J+pd4f54JmtIABH9II/fiCY7TUf6LeqQt8Wh/cPVYMH4lB96XpDCKmIwtI o+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hauke-m.de header.s=MBO0001 header.b=Ybn4OFRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si11540726edp.7.2020.12.21.15.43.48; Mon, 21 Dec 2020 15:44:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@hauke-m.de header.s=MBO0001 header.b=Ybn4OFRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726128AbgLUXmX (ORCPT + 99 others); Mon, 21 Dec 2020 18:42:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgLUXmX (ORCPT ); Mon, 21 Dec 2020 18:42:23 -0500 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7992C0613D3; Mon, 21 Dec 2020 15:41:42 -0800 (PST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4D0GFQ12YqzQlRQ; Tue, 22 Dec 2020 00:41:14 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hauke-m.de; s=MBO0001; t=1608594072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+SpruTXWYI7kkzwg63Wix/B+XVjogO4KHpq9u4eVk54=; b=Ybn4OFRR+VInPVGyZV73PMKEPvPapPVC1CzoUAMxyGHCd+9WGv1gzGf+lVS9QrtrhDgWSy nn/ceE4Rfw5TungqySaBY8qZ+OrHKwon8aza7v7pWj1a7BnhGLCht3KJyknv+T66ySY3Ax P0Z1kmQr6tpn5R3w2oGdxbVQZkPcyO6Gfcma2EJPp3BlTSgi2cgNVufffBCGN6HuPwuSXB y+o+Vcj/b8T4SyTwGVdrdrn/pSf4aiImISYyhP7fsTF3/rXpnMRsc0WD4O2dOHZSCy/TV4 UTKrQmtFbNPlD2S1BDqdPkDriBYNXITssU9aNkasLxMxE6h35EcKSXwG5ISO4A== Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id qLzPmxt2L1dn; Tue, 22 Dec 2020 00:41:09 +0100 (CET) Subject: Re: [PATCH] net: lantiq_etop: check the result of request_irq() To: Andrew Lunn , Masahiro Yamada Cc: "David S . Miller" , Jakub Kicinski , Networking , Linux Kernel Mailing List , Miguel Ojeda , Arnd Bergmann , Heiner Kallweit References: <20201221054323.247483-1-masahiroy@kernel.org> <20201221152645.GH3026679@lunn.ch> <20201221180433.GE3107610@lunn.ch> From: Hauke Mehrtens Message-ID: <3197556a-8df8-3959-895b-e4b82de904aa@hauke-m.de> Date: Tue, 22 Dec 2020 00:41:07 +0100 MIME-Version: 1.0 In-Reply-To: <20201221180433.GE3107610@lunn.ch> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-MBO-SPAM-Probability: X-Rspamd-Score: -6.06 / 15.00 / 15.00 X-Rspamd-Queue-Id: E311F1718 X-Rspamd-UID: a3b417 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/21/20 7:04 PM, Andrew Lunn wrote: > On Tue, Dec 22, 2020 at 12:59:08AM +0900, Masahiro Yamada wrote: >> On Tue, Dec 22, 2020 at 12:26 AM Andrew Lunn wrote: >>> >>> On Mon, Dec 21, 2020 at 02:43:23PM +0900, Masahiro Yamada wrote: >>>> The declaration of request_irq() in is marked as >>>> __must_check. >>>> >>>> Without the return value check, I see the following warnings: >>>> >>>> drivers/net/ethernet/lantiq_etop.c: In function 'ltq_etop_hw_init': >>>> drivers/net/ethernet/lantiq_etop.c:273:4: warning: ignoring return value of 'request_irq', declared with attribute warn_unused_result [-Wunused-result] >>>> 273 | request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv); >>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> drivers/net/ethernet/lantiq_etop.c:281:4: warning: ignoring return value of 'request_irq', declared with attribute warn_unused_result [-Wunused-result] >>>> 281 | request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv); >>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> >>>> Reported-by: Miguel Ojeda >>>> Signed-off-by: Masahiro Yamada >>>> --- >>>> >>>> drivers/net/ethernet/lantiq_etop.c | 13 +++++++++++-- >>>> 1 file changed, 11 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c >>>> index 2d0c52f7106b..960494f9752b 100644 >>>> --- a/drivers/net/ethernet/lantiq_etop.c >>>> +++ b/drivers/net/ethernet/lantiq_etop.c >>>> @@ -264,13 +264,18 @@ ltq_etop_hw_init(struct net_device *dev) >>>> for (i = 0; i < MAX_DMA_CHAN; i++) { >>>> int irq = LTQ_DMA_CH0_INT + i; >>>> struct ltq_etop_chan *ch = &priv->ch[i]; >>>> + int ret; >>>> >>>> ch->idx = ch->dma.nr = i; >>>> ch->dma.dev = &priv->pdev->dev; >>>> >>>> if (IS_TX(i)) { >>>> ltq_dma_alloc_tx(&ch->dma); >>>> - request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv); >>>> + ret = request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv); >>>> + if (ret) { >>>> + netdev_err(dev, "failed to request irq\n"); >>>> + return ret; >>> >>> You need to cleanup what ltq_dma_alloc_tx() did. >> >> >> Any failure from this function will roll back >> in the following paths: >> >> ltq_etop_hw_exit() >> -> ltq_etop_free_channel() >> -> ltq_dma_free() >> >> >> So, dma is freed anyway. >> >> One problem I see is, >> ltq_etop_hw_exit() frees all DMA channels, >> some of which may not have been allocated yet. >> >> If it is a bug, it is an existing bug. >> >> >>> >>>> + } >>>> } else if (IS_RX(i)) { >>>> ltq_dma_alloc_rx(&ch->dma); >>>> for (ch->dma.desc = 0; ch->dma.desc < LTQ_DESC_NUM; >>>> @@ -278,7 +283,11 @@ ltq_etop_hw_init(struct net_device *dev) >>>> if (ltq_etop_alloc_skb(ch)) >>>> return -ENOMEM; >> >> >> This -ENOMEM does not roll back anything here. >> >> As stated above, dma_free_coherent() is called. >> The problem is, ltq_etop_hw_exit() rolls back too much. >> >> If your requirement is "this driver is completely wrong. Please rewrite it", >> sorry, I cannot (unless I am paid to do so). >> >> I am just following this driver's roll-back model. >> >> Please do not expect more to a person who >> volunteers to eliminate build warnings. >> >> Of course, if somebody volunteers to rewrite this driver correctly, >> that is appreciated. > > Hi Hauke > > Do you still have this hardware? Do you have time to take a look at > the cleanup code? > > Thanks > Andrew > Hi Andrew, I have this hardware somewhere at home, but I never made it work. If I find some time I can have a loom at this problem in the next few weeks. Hauke