Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp793024ybl; Thu, 12 Dec 2019 05:06:41 -0800 (PST) X-Google-Smtp-Source: APXvYqw4w4iD1lIfiwNnB1Ka2wWO6ATKLRNv32yQeOfoTpdVk/dR36uFrAi5t1rOTTJkBbfxDomi X-Received: by 2002:a9d:32a2:: with SMTP id u31mr7548845otb.249.1576156001679; Thu, 12 Dec 2019 05:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576156001; cv=none; d=google.com; s=arc-20160816; b=jQnpBoBRpH4xHevRyHsESPb+Ldr20Dy/2J2ZidFCJd+HiTOXaBRTAJrkccyMuh7ryD 18VpqWkwrSoIDYIYhpWliZZcNR2PL1yYe+6NmIFsL4kHmWR9cFC2pSY6sytHHG6RuqHJ upf5Wi66rdSe1mpNKqqYzPh6w+6ZLa/xxwJtzDtzCSFSpQUM4tkNtGA7vGjjqZwMPOB3 HUNwU/I8/zjPaixv0POB3w826NrBi8yK3NPQVRzz5RrktpqS9Wi9Y5J2Jh8GCvHUDRmc 0l3ykx5pIYU4Gly3Xt4GO26SeHS8BUn/B7N7ExOL6J4H4DBK+znT8upgM0pxi0/BtJ1V miLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=QEwKnSky4Es2OcqctIGMRcK62xhez8oW7ItQ/WhQnHU=; b=t7oIlzfV4l0BF6BaSicls7m68Y6lX15M5Y0YeJvhSEsiSJxM+zD68TFrQtPIbadiGQ H8b8hrsqFp+zuykBHWWsMq89pYAEFHYGxiDoYL2p1Vp7x+EzbWDbFaNopLE359dnFhf5 PgqbDi0DQPwczgogXGfNZMqx6xDDkOYf3rjIKPH/JNq3+uceBKcNSrYrFTSDjiGaWWkS OtoQ0/2AHkHFuLP9UcP/yIWAeJooUU5ApkT7QFVM3SoVhc4nArOzqFVKA5DFGdyMf/pv FwWquoG2C8RiznpvJ2MGH9E1r0H+qvGHWF6vDmuC1Opy2yQoYdg5cR3mhXXPWiLBfbyp HhSA== 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 v49si3207921otb.253.2019.12.12.05.06.28; Thu, 12 Dec 2019 05:06:41 -0800 (PST) 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 S1729367AbfLLNFm (ORCPT + 99 others); Thu, 12 Dec 2019 08:05:42 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:45790 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729297AbfLLNFm (ORCPT ); Thu, 12 Dec 2019 08:05:42 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1ifO9z-0003rz-Vu; Thu, 12 Dec 2019 14:05:40 +0100 Date: Thu, 12 Dec 2019 14:05:39 +0100 From: Sebastian Andrzej Siewior To: Rob Herring Cc: devicetree@vger.kernel.org, Frank Rowand , "linux-kernel@vger.kernel.org" , Michael Ellerman , Segher Boessenkool Subject: Re: [PATCH] of: Rework and simplify phandle cache to use a fixed size Message-ID: <20191212130539.loxpr2hbfcodh4gz@linutronix.de> References: <20191211232345.24810-1-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-12-11 17:48:54 [-0600], Rob Herring wrote: > > - if (phandle_cache) { > > - if (phandle_cache[masked_handle] && > > - handle == phandle_cache[masked_handle]->phandle) > > - np = phandle_cache[masked_handle]; > > - if (np && of_node_check_flag(np, OF_DETACHED)) { > > - WARN_ON(1); /* did not uncache np on node removal */ > > - of_node_put(np); > > - phandle_cache[masked_handle] = NULL; > > - np = NULL; > > - } > > + if (phandle_cache[handle_hash] && > > + handle == phandle_cache[handle_hash]->phandle) > > + np = phandle_cache[handle_hash]; > > + if (np && of_node_check_flag(np, OF_DETACHED)) { > > + WARN_ON(1); /* did not uncache np on node removal */ > > BTW, I don't think this check is even valid. If we failed to detach > and remove the node from the cache, then we could be accessing np > after freeing it. this is kmalloc()ed memory which is always valid. If the memory is already re-used then handle == phandle_cache[handle_hash]->phandle will fail (the check, not the memory access itself). If the check remains valid then you can hope for the OF_DETACHED flag to trigger the warning. > Rob Sebastian