From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFB8BCCA47B for ; Fri, 10 Jun 2022 20:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350522AbiFJUIs (ORCPT ); Fri, 10 Jun 2022 16:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348721AbiFJUIr (ORCPT ); Fri, 10 Jun 2022 16:08:47 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E424323EFAA; Fri, 10 Jun 2022 13:08:45 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id r187-20020a1c44c4000000b0039c76434147so1642428wma.1; Fri, 10 Jun 2022 13:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=EYdxdXjqZnMfe3vNUEt1qvnu5edzLozRvBmutng2gcs=; b=CwmfAF6XHzbKO8jEH1gk+bM/1vpPQGL/FBas2sxdEfvaPOWCrmy31A4DGlV+qRbNLh EhE7R/0Apge67rflwIqv8xb8iI3MVz4tH/cjgvlR0njUgo8D/mQ1I7jC3EKVSvYMwwcI sbxI1wxllvZ09BnK2w2SbAc5pxLTidgyMANYo96BcCZ/obK1SZsjQnLrn4I8/dPp07XC G1yQR1Yy0wNiRGatiMcWPC3BBg8FGpQTCb/lIQdyvipx939yxhZ6fvPdX3cj8ChHvy5k k6USF7TyLBfpolWfhPNfaJpv5ZIkxehFF9XkoRvK3oVX5QPgU1PKY2VQfWO+6rp3rB/o VRhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=EYdxdXjqZnMfe3vNUEt1qvnu5edzLozRvBmutng2gcs=; b=H3CPzW8Euz8LNLgs3k/Y57+KlLESEQOURkXzEsPUgqCY7RCSnPBecMU8p6EyXvKcno b92PY2kWHyTlJ5t4sRshYsEwr8QFkaCTgEwx27NeSHUy8ilePt2cdtkja2Crqint2fj5 Z6ZRrcGa05fMnf5KB5ZoQKz9mzxfVbS7wLuJGoEtXl5Kg49C1iyuMM4WhEkwS2fdR9B4 D+eNxe2E7RwKn+2VGYJq7PoQAEXiqYlw6ilaLhXBrRMo3lHVtXe8OsppgyLFKeZ9rHii OcokeAOs9VkdLNKT4iPmScHOwHRXr5Bdy0ubN4KOq2JfIWHP0L4+cfZ7ykRdRmKHG7v5 XlKg== X-Gm-Message-State: AOAM533wYhCix341fNDynKC+HvcNXl3aPjW5Z7NXPt4avLMIfJuUrotf MOAZip/RuTX0YVSIE8y6muY= X-Google-Smtp-Source: ABdhPJzFMI/kZj6Y7ZsIIRkgwHejQ91g4pjv9UVjVQoEdMHpUhK/4CORgOZeBhdrhfbjPGUylvA40Q== X-Received: by 2002:a1c:f704:0:b0:39c:6684:b375 with SMTP id v4-20020a1cf704000000b0039c6684b375mr1346597wmh.66.1654891724476; Fri, 10 Jun 2022 13:08:44 -0700 (PDT) Received: from ?IPv6:2001:a61:136e:3c01:8bd4:cf6f:76f1:a861? ([2001:a61:136e:3c01:8bd4:cf6f:76f1:a861]) by smtp.gmail.com with ESMTPSA id e10-20020a5d4e8a000000b00210320d9fbfsm436482wru.18.2022.06.10.13.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 13:08:44 -0700 (PDT) Message-ID: Subject: Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it From: Nuno =?ISO-8859-1?Q?S=E1?= To: Andy Shevchenko , Nuno =?ISO-8859-1?Q?S=E1?= Cc: dl-linux-imx , Linux-Renesas , "open list:BROADCOM NVRAM DRIVER" , linux-arm Mailing List , chrome-platform@lists.linux.dev, Lad Prabhakar , "moderated list:ARM/Mediatek SoC support" , linux-stm32@st-md-mailman.stormreply.com, linux-arm-msm , linux-iio , OpenBMC Maillist , Cai Huoqing , Benjamin Fair , Jishnu Prakash , Linus Walleij , Lars-Peter Clausen , Alexandre Torgue , Amit Kucheria , Andy Gross , Michael Hennerich , Haibo Chen , Benson Leung , "Rafael J. Wysocki" , Alexandre Belloni , Christophe Branchereau , Patrick Venture , Arnd Bergmann , Nancy Yuen , Sascha Hauer , Daniel Lezcano , Gwendal Grignou , Saravanan Sekar , Tali Perry , Maxime Coquelin , Paul Cercueil , Thara Gopinath , Avi Fishman , Lorenzo Bianconi , Claudiu Beznea , Pengutronix Kernel Team , Fabrice Gasnier , Matthias Brugger , Tomer Maimon , Bjorn Andersson , Nicolas Ferre , Jonathan Cameron , Zhang Rui , Shawn Guo , Guenter Roeck , Fabio Estevam , Olivier Moysan , Eugen Hristev , Miquel Raynal Date: Fri, 10 Jun 2022 22:08:41 +0200 In-Reply-To: References: <20220610084545.547700-1-nuno.sa@analog.com> <20220610084545.547700-21-nuno.sa@analog.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote: > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá wrote: > > > > 'of_node_put()' can potentially release the memory pointed to by > > 'iiospec.np' which would leave us with an invalid pointer (and we > > would > > still pass it in 'of_xlate()'). As such, we can only release the > > node > > after we are done with it. > > The question you should answer in the commit message is the > following: > "Can an OF node, attached to a struct device, be gone before the > device itself?" If it so, then patch is good, otherwise there is no > point in this patch in the first place. > Yeah, I might be wrong but from a quick look... yes, I think the node can be gone before the device. Take a look on the spi or i2c of_notify handling and you can see that the nodes are get/put on the add/remove notifcation. Meaning that the node lifespan is not really attached to the device lifespan. If it was, I would expect to see of_node_put() on the device release() function... Again, I might be wrong and I admit I was not sure about including this patch because it's a very unlikely scenario even though I think, in theory, a possible one. - Nuno Sá