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 X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C20FFC67839 for ; Thu, 13 Dec 2018 02:57:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E4D820851 for ; Thu, 13 Dec 2018 02:57:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E4D820851 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbeLMC5S (ORCPT ); Wed, 12 Dec 2018 21:57:18 -0500 Received: from ozlabs.org ([203.11.71.1]:43985 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbeLMC5R (ORCPT ); Wed, 12 Dec 2018 21:57:17 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 43Fdd71xbWz9s8r; Thu, 13 Dec 2018 13:57:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Frank Rowand , Rob Herring Cc: mwb@linux.vnet.ibm.com, linuxppc-dev , Tyrel Datwyler , tlfalcon@linux.vnet.ibm.com, minkim@us.ibm.com, devicetree@vger.kernel.org, "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH v03] powerpc/mobility: Fix node detach/rename problem In-Reply-To: <48aa028d-b786-7704-70ff-75a6d2321474@gmail.com> References: <871s6oxkdf.fsf@concordia.ellerman.id.au> <48aa028d-b786-7704-70ff-75a6d2321474@gmail.com> Date: Thu, 13 Dec 2018 13:57:16 +1100 Message-ID: <877egew2ur.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Frank Rowand writes: > On 12/11/18 8:07 AM, Rob Herring wrote: >> On Tue, Dec 11, 2018 at 7:29 AM Michael Ellerman wrote: ... >>> diff --git a/drivers/of/base.c b/drivers/of/base.c >>> index 09692c9b32a7..d8e4534c0686 100644 >>> --- a/drivers/of/base.c >>> +++ b/drivers/of/base.c >>> @@ -1190,6 +1190,10 @@ struct device_node *of_find_node_by_phandle(phandle handle) >>> if (phandle_cache[masked_handle] && >>> handle == phandle_cache[masked_handle]->phandle) >>> np = phandle_cache[masked_handle]; >>> + >>> + /* If we find a detached node, remove it */ >>> + if (of_node_check_flag(np, OF_DETACHED)) >>> + np = phandle_cache[masked_handle] = NULL; > > The bug you found exposes a couple of different issues, a little bit > deeper than the proposed fix. I'll work on a fuller fix tonight or > tomorrow. OK thanks. >> I'm wondering if we should explicitly remove the node from the cache >> when we set OF_DETACHED. Otherwise, it could be possible that the node >> pointer has been freed already. Or maybe we need both? > > Yes, it should be explicitly removed. I may also add in a paranoia check in > of_find_node_by_phandle(). That seems best to me. cheers