Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4348018pxu; Mon, 21 Dec 2020 10:07:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHqVYjXpJn7f+RFbI020JI8xOc8cJfyvWd3m3hv4QYrpu89ecpcUXv0uXYcShqCzB0tAbA X-Received: by 2002:a17:907:435c:: with SMTP id oc20mr16821663ejb.286.1608574039745; Mon, 21 Dec 2020 10:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608574039; cv=none; d=google.com; s=arc-20160816; b=EEjAvJWkawGD6ibeWlbeMT/qOpicDCe7aDQUgsQEbH4lYGBH9yhMVdwA0wrROU7yqe fi38mli9720QAUNWqkTFMJkDvv2pD8ht4lWQxolcepxN+WWeJbAx68kkpIcwYvbQ6GQ+ xz1CXYK42Uy4J1gc4mXU+8KKsnQ92KTEyKuRTHOjzh287yDAMnV+aLU48G++ddDoZUKu SvLibHbQMdCYO9dXMCy9R3waN4CsD3qkEtjZbtuHXqfPRhTgOzj9V6lFXr/cB5os6FaF 1fqj4sEmPYH86N5XFDZARwnjqHSnb4Xysb+53J7zIWX2HMZ3vrjz7VbuafF7iE18/Kwk bFVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=NBkr+Ubc9twkwipdb0I/YNgr4XbA/omP7UVt27pT7YQ=; b=CeOR0C9CUQSdCtu0xcqY3bs4YLOEduYtaPfDlDUj7Qnsei/0jY9GLmqxxIeR11rh7s /Hf9lJwlQy1vsNQxZpxhZ2iFUqREMh21KGVCwTmzLrgO9QEYicv0SEvqXUU+p0R2plEx U7KskENfMYQG0kzXy0czVXDd852YYStAB5cSs+lLM2yycYEj7xZ4l4aigzs0wW+TnyC3 DY5G0qVGK5Z730yhQawCDBZ4HQ9BaKPPVElSC7C8OF4bjr9Ju5hNcO1qDQ3RrWuLYFuQ rc5atqxokDAVOc16/bxN4d0qtrTIRDu1k+U/jSkRnU8b1FjftgJevF8hJoXdbCqKeStK NxPA== ARC-Authentication-Results: i=1; mx.google.com; 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 e8si11064338edq.377.2020.12.21.10.06.57; Mon, 21 Dec 2020 10:07:19 -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; 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 S1726396AbgLUSFV (ORCPT + 99 others); Mon, 21 Dec 2020 13:05:21 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:35974 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbgLUSFU (ORCPT ); Mon, 21 Dec 2020 13:05:20 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1krPXt-00DBHi-F6; Mon, 21 Dec 2020 19:04:33 +0100 Date: Mon, 21 Dec 2020 19:04:33 +0100 From: Andrew Lunn To: Masahiro Yamada , Hauke Mehrtens Cc: "David S . Miller" , Jakub Kicinski , Networking , Linux Kernel Mailing List , Miguel Ojeda , Arnd Bergmann , Heiner Kallweit Subject: Re: [PATCH] net: lantiq_etop: check the result of request_irq() Message-ID: <20201221180433.GE3107610@lunn.ch> References: <20201221054323.247483-1-masahiroy@kernel.org> <20201221152645.GH3026679@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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