Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9014378ybi; Wed, 10 Jul 2019 03:16:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqya9dh+FberqM2qWxqdNwtmWPkBHvDSjHreHqplCzjt+FEcKd8aIfmTGJrJIq/cWLUFAeqG X-Received: by 2002:a17:90a:2525:: with SMTP id j34mr6224410pje.11.1562753766280; Wed, 10 Jul 2019 03:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562753766; cv=none; d=google.com; s=arc-20160816; b=x+MdH/Iq0YHdFxh7DDbLhIejjwBx5wrbRqdYjIv9ZYeiYHJ6/AtbGbs255ApGSg5G4 a/Iy+6/kDQ4NJZ8fXvCxmXinRP1SCimcXEzXEEPkyrG6QKaG3s4HA3mw94SAvUOUwgcJ o6vE0eC/ZpybYwykiyp4G5zC59/6AGMp0ft9fadG63nSMwC+DLt1Pd3kbl7kUaajIcdb raGv4mfJ1wCMa/RziRxd3rwbvpG9soRLQ5SA9r6LHtCTyVufl+MuGPLdqxQmlFVmGxIy 1v8rSMG6Y1G4WawRoprAmRAwBW9+cEOHN8gLx9P0YCF/uv4FH9kiGDvQ6scqCtM/0QFL 1aQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=sMQ20HN1HkUQ5iXeyevGIec1BiPAteEIkUj5csryX4M=; b=HYsKu7qHvKGR+8Hjq7w2RcxrztPI3mXINhpQCTvXm4KA3oRCLLGUsLx0NegINjOYjd gqXIaL53O5vvLTwe2iLrGyoA2k5VT6vI3Bk28XDDSd8h0BwdqduzXRbk/wqBuD26iJPp gv42uCml2JpKZTzb6oiXR6yRp21aaiCG/EYBro4RbTHovCjQUYweo2C+m8IqsaW2d5ac RYHygi12c027s2payoDTzLlySH8c0c2Ww/xpECgqh+zDSyxdxbS6Y5vitVvT0ghGFAYY kQd4AjyInHnhZ7nYY50wdfkjtGzKvdTY+eBBFJK0IdWjn/1XiVissqMmNJqlMeB12XUK Ravg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si1745021plt.276.2019.07.10.03.15.50; Wed, 10 Jul 2019 03:16:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfGJKNQ (ORCPT + 99 others); Wed, 10 Jul 2019 06:13:16 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:36895 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbfGJKNQ (ORCPT ); Wed, 10 Jul 2019 06:13:16 -0400 Received: by mail-oi1-f193.google.com with SMTP id t76so1187039oih.4; Wed, 10 Jul 2019 03:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sMQ20HN1HkUQ5iXeyevGIec1BiPAteEIkUj5csryX4M=; b=PogKRyCeV6WJxMOTIuNo1D1IqzdIsVHnScXRn7SUoxFp82wmm6VXfDLKk8no1su/qq j+FQgqsyQaHYQT1RsGowx2nF2b5kSQbiV1HpPcdDW4203eKi7j3pbC6sjn/sZhhIDYhw 2CoqveccXMxfSE/V1STFLW7cdJ2vkp3TZsT4Yorm2YYTdRC7Xyg1tQJ/DyqO/ItAhfnj V+DHeCH4Gywy3OPXohY9oZufL5MKNZG5Kz0qrhATZemAS5NzEGfHbfQ1nLuKqgk3MSca x2K+Uvty8d3ZSJmFqIkRCT56on76edK7QPsmeNKHEFAxlAmIWvj/VIbb5saMh23M+RpU x8bw== X-Gm-Message-State: APjAAAW/ZyFXSO5tBhCApcszpdH5shvoCDLsldDxfY9JlKZLz5I4Eh4X q4MGLb90pmP6Bgt1cWVxF6P2o7pxn8eGYd5CFqs= X-Received: by 2002:aca:bd43:: with SMTP id n64mr2639388oif.148.1562753595363; Wed, 10 Jul 2019 03:13:15 -0700 (PDT) MIME-Version: 1.0 References: <20190710090852.9239-1-brgl@bgdev.pl> <510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au> In-Reply-To: <510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au> From: Geert Uytterhoeven Date: Wed, 10 Jul 2019 12:13:04 +0200 Message-ID: Subject: Re: [PATCH 1/2] gpio: em: remove the gpiochip before removing the irq domain To: Phil Reid Cc: Bartosz Golaszewski , Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Bartosz Golaszewski , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Phil, On Wed, Jul 10, 2019 at 11:37 AM Phil Reid wrote: > On 10/07/2019 17:08, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > In commit 8764c4ca5049 ("gpio: em: use the managed version of > > gpiochip_add_data()") we implicitly altered the ordering of resource > > freeing: since gpiochip_remove() calls gpiochip_irqchip_remove() > > internally, we now can potentially use the irq_domain after it was > > destroyed in the remove() callback (as devm resources are freed after > > remove() has returned). > > > > Use devm_add_action() to keep the ordering right and entirely kill > > the remove() callback in the driver. > > > > Reported-by: Geert Uytterhoeven > > Fixes: 8764c4ca5049 ("gpio: em: use the managed version of gpiochip_add_data()") > > Cc: stable@vger.kernel.org > > Signed-off-by: Bartosz Golaszewski > > --- a/drivers/gpio/gpio-em.c > > +++ b/drivers/gpio/gpio-em.c > > @@ -333,39 +340,32 @@ static int em_gio_probe(struct platform_device *pdev) > > return -ENXIO; > > } > > > > + ret = devm_add_action(&pdev->dev, > > + em_gio_irq_domain_remove, p->irq_domain); > > Could devm_add_action_or_reset be used? Thank you very much for bringing this function to my attention! I was just wondering if devm_add_action() should call the action on failure, as this is what most callers seem to do anyway. > > > + if (ret) { > > + irq_domain_remove(p->irq_domain); > > + return ret; > > + } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds