Re: [PATCH v2] ACPI / hotplug / PCI: lost acpiphp_put_context in acpiphp_grab_context()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/23/20 7:29 PM, Rafael J. Wysocki wrote:
> On Tuesday, June 23, 2020 1:17:43 AM CEST Vasily Averin wrote:
>> v2: followed to rafael@'s proposal
>> Fixes: edf5bf34d408 ("ACPI / dock: Use callback pointers from devices' ACPI hotplug contexts")
>> Signed-off-by: Vasily Averin <vvs@xxxxxxxxxxxxx>
> Thanks for following my suggestion, but it occurred to me that it could still be
> done in a better way.
> 
> So instead of the above I'd prefer to apply the following change (added PCI and Bjorn
> for visibility):

Thank you,
however could you please tell me what do you think about following variant?

 drivers/pci/hotplug/acpiphp_glue.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index b4c92cee13f8..5875c3654b52 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -119,16 +119,17 @@ static inline void put_bridge(struct acpiphp_bridge *bridge)
 
 static struct acpiphp_context *acpiphp_grab_context(struct acpi_device *adev)
 {
-	struct acpiphp_context *context;
+	struct acpiphp_context *c, *context = NULL;
 
 	acpi_lock_hp_context();
-	context = acpiphp_get_context(adev);
-	if (!context || context->func.parent->is_going_away) {
-		acpi_unlock_hp_context();
-		return NULL;
+	c = acpiphp_get_context(adev);
+	if (c) {
+		if (c->func.parent->is_going_away == false) {
+			get_bridge(c->func.parent);
+			context = c;
+		}
+		acpiphp_put_context(c);
 	}
-	get_bridge(context->func.parent);
-	acpiphp_put_context(context);
 	acpi_unlock_hp_context();
 	return context;
 }



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux