From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932209AbdJXNni (ORCPT ); Tue, 24 Oct 2017 09:43:38 -0400 Received: from mga01.intel.com ([192.55.52.88]:9987 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692AbdJXNne (ORCPT ); Tue, 24 Oct 2017 09:43:34 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,427,1503385200"; d="scan'208";a="1209453070" Subject: Re: [PATCH] device property: Track owner device of device property To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, "Rafael J . Wysocki" , Lukas Wunner , stable@vger.kernel.org References: <20171009132837.1096-1-jarkko.nikula@linux.intel.com> <20171020143423.GA27882@kroah.com> From: Jarkko Nikula Message-ID: Date: Tue, 24 Oct 2017 16:41:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171020143423.GA27882@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/2017 05:34 PM, Greg Kroah-Hartman wrote: >> @@ -938,6 +940,7 @@ int device_add_properties(struct device *dev, >> >> p->fwnode.ops = &pset_fwnode_ops; >> set_secondary_fwnode(dev, &p->fwnode); >> + p->dev = dev; > > Don't you also need to increment the reference counter here? Or how is > it assured that it will not go away? > I need to scratch my head on this. It sounds more robust to track references and remove properties when last reference is dropped in device_remove_properties(). What I don't know are properties be expected to be copied and be usable for another device for instance by ACPI_COMPANION_SET(). I can figure out case where properties are added to one device, another device gets reference to them via ACPI_COMPANION_SET() and properties get freed when the first device is removed. But should the second device be able to use those properties at first place? Rafael: What's you opinion: should there be reference counting for device properties? Initial increment in device_add_properties(), other around ACPI_COMPANION_SET()/set_primary_fwnode() and decrementing in device_remove_properties(). -- Jarkko