Patch "platform/x86/dell/dell-rbtn: Fix resources leaking on error path" has been added to the 6.1-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    platform/x86/dell/dell-rbtn: Fix resources leaking on error path

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     platform-x86-dell-dell-rbtn-fix-resources-leaking-on.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9b1c8e877e552181d40f754053a01aa516a158e7
Author: Michal Wilczynski <michal.wilczynski@xxxxxxxxx>
Date:   Tue Jun 13 11:43:10 2023 +0300

    platform/x86/dell/dell-rbtn: Fix resources leaking on error path
    
    [ Upstream commit 966cca72ab20289083521a385fa56035d85a222d ]
    
    Currently rbtn_add() in case of failure is leaking resources. Fix this
    by adding a proper rollback. Move devm_kzalloc() before rbtn_acquire(),
    so it doesn't require rollback in case of failure. While at it, remove
    unnecessary assignment of NULL to device->driver_data and unnecessary
    whitespace, plus add a break for the default case in a switch.
    
    Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
    Suggested-by: Pali Rohár <pali@xxxxxxxxxx>
    Fixes: 817a5cdb40c8 ("dell-rbtn: Dell Airplane Mode Switch driver")
    Signed-off-by: Michal Wilczynski <michal.wilczynski@xxxxxxxxx>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
    Acked-by: Rafael J. Wysocki <rafael@xxxxxxxxxx>
    Reviewed-by: Pali Rohár <pali@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230613084310.2775896-1-michal.wilczynski@xxxxxxxxx
    Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c
index aa0e6c9074942..c8fcb537fd65d 100644
--- a/drivers/platform/x86/dell/dell-rbtn.c
+++ b/drivers/platform/x86/dell/dell-rbtn.c
@@ -395,16 +395,16 @@ static int rbtn_add(struct acpi_device *device)
 		return -EINVAL;
 	}
 
+	rbtn_data = devm_kzalloc(&device->dev, sizeof(*rbtn_data), GFP_KERNEL);
+	if (!rbtn_data)
+		return -ENOMEM;
+
 	ret = rbtn_acquire(device, true);
 	if (ret < 0) {
 		dev_err(&device->dev, "Cannot enable device\n");
 		return ret;
 	}
 
-	rbtn_data = devm_kzalloc(&device->dev, sizeof(*rbtn_data), GFP_KERNEL);
-	if (!rbtn_data)
-		return -ENOMEM;
-
 	rbtn_data->type = type;
 	device->driver_data = rbtn_data;
 
@@ -420,10 +420,12 @@ static int rbtn_add(struct acpi_device *device)
 		break;
 	default:
 		ret = -EINVAL;
+		break;
 	}
+	if (ret)
+		rbtn_acquire(device, false);
 
 	return ret;
-
 }
 
 static void rbtn_remove(struct acpi_device *device)
@@ -442,7 +444,6 @@ static void rbtn_remove(struct acpi_device *device)
 	}
 
 	rbtn_acquire(device, false);
-	device->driver_data = NULL;
 }
 
 static void rbtn_notify(struct acpi_device *device, u32 event)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux