Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1929229ybg; Fri, 5 Jun 2020 00:57:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfXDExFxC+tHCOnKnxRcSQo4/Icjds17HHpNm+pe6YtWy86g9PYEE9HOmhFjBmR7m/vkyo X-Received: by 2002:aa7:c403:: with SMTP id j3mr8162374edq.294.1591343867949; Fri, 05 Jun 2020 00:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591343867; cv=none; d=google.com; s=arc-20160816; b=UbD1Er6xRKHkSTuF0cj8/NtFobbsTpnf5YGbbkpbPME9Hwy9PV/xHsSR/zxQZw5KnB SHph0xqXQBW+aRCxWBN+PWdb8iuJFrWkGDy33HtC2/8JdQw/fCGjh573I5MpUMZbs6/6 +cVHc84W4UkFhCVxYr3RTYZEtRb7PqgNqkSUl7B7/+l76Fdsh+njAbOXXGvCo4qndqNM 2RAPObIwgkkqDocioUgQ4YZkvbQzTOhMQPE0xjYKDVm+cQXuinOYzHrRQxEbQdC3Xyfr nqgmWsgnrDUsNsvX1HOQ5SXxTGG9fN08V65oXrYawBR72V2bDhPGil2mv9h/X5RFqKO5 zcKA== 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 :dkim-signature; bh=3SOFfPXG/EeNiHXt20LdKgwrhDQ/whsomih/tNU3T4w=; b=vl35R5X8L+bDGeHvfHK5gIMefwD0EO6DXq9SfSyiStmqltN6La4m70+xa+g1ptAHEy 9IL3wDHAiYlhMzMtgHTdEz2cK/I+O7yMdH0KNvR/3sIMETmuF4qbiZyDUIiZ9bN1E+2m PFPYYMqZH0toyRnr7FeNy5FHm5PASiCqPuAks2CtKvpKvOKdjcj4wiUoXnQOoGfC9vIo 1LwVOD1/EiJIGuLkYRSjBj1Ghe/E2ObQ0A4VCcXOmQkCUJao4inA6mfF2ayQR6MRD5Kv Okw88D4s4h6QLp4DLVqGVNAqFn0zZL3YMiNF2MujGmPd2VR2QivOBm3u6c9DE0aJsouy D+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bEu42y6a; 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 jp13si2968351ejb.312.2020.06.05.00.57.24; Fri, 05 Jun 2020 00:57:47 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=bEu42y6a; 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 S1726182AbgFEHzC (ORCPT + 99 others); Fri, 5 Jun 2020 03:55:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:51598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbgFEHzC (ORCPT ); Fri, 5 Jun 2020 03:55:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45DEB206E6; Fri, 5 Jun 2020 07:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591343701; bh=F5ckDxBoTfzTlsdoPDm6iMTBJW8h6mJ8lDlune7vUxc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bEu42y6aSWTCJvNfoCSag8QnhYCSoQ4EaYh7cp2+gT8XhrHKyPEoUuoEotdiuVT1s uomaHTj67y2S71PQxLmaGd3yF8mHnOxY9cMs4m0ETkKBd9XHpg8sneCg+UQHrWfC7w nD0gxUpx3hgPg/b0ddvC/dJ3QUttev3LAhWgtXjA= Date: Fri, 5 Jun 2020 09:54:59 +0200 From: Greg Kroah-Hartman To: Jordan Hand Cc: Heikki Krogerus , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-next@vger.kernel.org Subject: Re: [PATCH] software node: recursively unregister child swnodes Message-ID: <20200605075459.GB2209311@kroah.com> References: <20200604193623.16946-1-jorhand@linux.microsoft.com> <20200604201523.GA1308830@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 Thu, Jun 04, 2020 at 01:57:01PM -0700, Jordan Hand wrote: > On 6/4/20 1:15 PM, Greg Kroah-Hartman wrote: > > On Thu, Jun 04, 2020 at 12:36:23PM -0700, jorhand@linux.microsoft.com wrote: > > > From: Jordan Hand > > > > > > If a child swnode is unregistered after it's parent, it can lead to > > > undefined behavior. > > > > Crashing the system is not really "undefined" :) > > Fair point :) > > > > > > When a swnode is unregistered, recursively free it's children to avoid > > > this condition. > > > > Are you sure? Why would you be unregistering a child after it's parent? > > Why not just do not do that? > > > > The main motivation for doing this was to support > `software_node_unregister_nodes` so that the passed list of nodes does not > need to be ordered in any particular way. > > I suppose another way to do this would be to add a new function > `fwnode_remove_software_node_recursive` and just call that from > `software_node_unregister_nodes`. > > That said, I suppose just ordering the nodes so that children come before > parents would also be fine. My thinking was just that accepting any node > ordering is simpler. Right now, the way the driver model and sysfs/kobjects work is that all objects must be removed in child-first order. The problem of your change where you want to try to remove the devices in parent-first order is that you do not really know if you still have a reference to a child device somewhere else, which would prevent this all from happening correctly, right? So if you "know" it is safe to drop a child, that's great, and expected. Don't work to make this one tiny user of the kobjects (which I'm still not quite sure why they are kobjects and not devices), do things in a different way from the rest of the kernel without a strong reason to do so. thanks, greg k-h