Skip to content

Commit f0f7a3f

Browse files
Qiu Wenboij-intel
authored andcommitted
platform/x86: int3472: Fix double free of GPIO device during unregister
regulator_unregister() already frees the associated GPIO device. On ThinkPad X9 (Lunar Lake), this causes a double free issue that leads to random failures when other drivers (typically Intel THC) attempt to allocate interrupts. The root cause is that the reference count of the pinctrl_intel_platform module unexpectedly drops to zero when this driver defers its probe. This behavior can also be reproduced by unloading the module directly. Fix the issue by removing the redundant release of the GPIO device during regulator unregistration. Cc: stable@vger.kernel.org Fixes: 1e5d088 ("platform/x86: int3472: Stop using devm_gpiod_get()") Signed-off-by: Qiu Wenbo <qiuwenbo@kylinsec.com.cn> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Link: https://patch.msgid.link/20251028063009.289414-1-qiuwenbo@gnome.org Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 34cbd6e commit f0f7a3f

2 files changed

Lines changed: 1 addition & 5 deletions

File tree

drivers/platform/x86/intel/int3472/clk_and_regulator.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,12 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
245245
if (IS_ERR(regulator->rdev))
246246
return PTR_ERR(regulator->rdev);
247247

248-
int3472->regulators[int3472->n_regulator_gpios].ena_gpio = gpio;
249248
int3472->n_regulator_gpios++;
250249
return 0;
251250
}
252251

253252
void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472)
254253
{
255-
for (int i = 0; i < int3472->n_regulator_gpios; i++) {
254+
for (int i = 0; i < int3472->n_regulator_gpios; i++)
256255
regulator_unregister(int3472->regulators[i].rdev);
257-
gpiod_put(int3472->regulators[i].ena_gpio);
258-
}
259256
}

include/linux/platform_data/x86/int3472.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ struct int3472_gpio_regulator {
100100
struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
101101
char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH];
102102
char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
103-
struct gpio_desc *ena_gpio;
104103
struct regulator_dev *rdev;
105104
struct regulator_desc rdesc;
106105
};

0 commit comments

Comments
 (0)