VYPR
Unrated severityNVD Advisory· Published May 27, 2026· Updated May 27, 2026

CVE-2026-45936

CVE-2026-45936

Description

In the Linux kernel, the following vulnerability has been resolved:

power: supply: goldfish: Fix use-after-free in power_supply_changed()

Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the power_supply handle, means that the power_supply handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the power_supply handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling power_supply_changed() with a freed power_supply handle. Which usually crashes the system or otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during probe(); the possibility of an interrupt firing _before_ registering the power_supply handle. This would then lead to the nasty situation of using the power_supply handle *uninitialized* in power_supply_changed().

Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the power_supply handle.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

In the Linux kernel's goldfish power supply driver, improper ordering of devm_ resource deallocation causes a use-after-free in power_supply_changed().

Vulnerability

In the Linux kernel goldfish power supply driver, the devm_ variant for requesting the IRQ is allocated before the devm_ variant for allocating/registering the power_supply handle. Since devm_ deallocates in reverse order, during removal the power_supply handle is freed before the IRQ handler is unregistered, leading to a use-after-free when power_supply_changed() is called with a freed handle. This affects kernels prior to the fix. [1]

Exploitation

An attacker must have the ability to trigger an interrupt on the goldfish device (e.g., through physical access or emulator control) during the removal of the driver (e.g., device hot-unplug or driver unbind). The race window exists between freeing the power_supply handle and unregistering the IRQ handler. A similar issue during probe could occur if an interrupt fires before the handle is registered. [1]

Impact

A successful exploit leads to a use-after-free, which can cause a system crash (denial of service) or potentially allow memory corruption. The attacker may be able to leverage this into privilege escalation, though the specific impact depends on kernel configuration and memory state. [1]

Mitigation

The fix is to reorder the resource allocation so that the IRQ is requested after the power_supply handle is registered. This is achieved in commits [1] and [2] which are part of stable kernel updates. Users should apply the latest stable kernel updates from their distribution. No workaround is provided; updating is required. [1][2]

AI Insight generated on May 27, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

1

Patches

16
bad8b61eb505

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 5.15.202via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index bf1754355c9fcd..c7502fa8efa7b3 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -226,12 +226,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     		return -ENODEV;
     	}
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -247,6 +241,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
33751e28842b

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 6.1.165via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index a58d713d75ce81..4d204f0e18532f 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -245,6 +239,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
77ea437faa4c

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 6.6.128via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index a58d713d75ce81..4d204f0e18532f 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -245,6 +239,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
4350505e82b4

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 6.12.75via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
8c89aade8335

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 6.18.14via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
0b29ffe4090a

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 6.19.4via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
b2ce982e2e0c

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 7.0via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
589d4fe56713

power: supply: goldfish: Fix use-after-free in power_supply_changed()

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.gitWaqar HameedDec 20, 2025Fixed in 5.10.252via kernel-cna
1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index bf1754355c9fcd..c7502fa8efa7b3 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -226,12 +226,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     		return -ENODEV;
     	}
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -247,6 +241,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
b2ce982e2e0c

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
0b29ffe4090a

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
33751e28842b

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index a58d713d75ce81..4d204f0e18532f 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -245,6 +239,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
4350505e82b4

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
589d4fe56713

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index bf1754355c9fcd..c7502fa8efa7b3 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -226,12 +226,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     		return -ENODEV;
     	}
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -247,6 +241,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
77ea437faa4c

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index a58d713d75ce81..4d204f0e18532f 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -245,6 +239,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
bad8b61eb505

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index bf1754355c9fcd..c7502fa8efa7b3 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -226,12 +226,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     		return -ENODEV;
     	}
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = power_supply_register(&pdev->dev, &ac_desc, &psy_cfg);
    @@ -247,6 +241,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     
     	platform_set_drvdata(pdev, data);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    
8c89aade8335

power: supply: goldfish: Fix use-after-free in power_supply_changed()

1 file changed · +6 7
  • drivers/power/supply/goldfish_battery.c+6 7 modified
    diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
    index 479195e35d734a..5aa24e4dc4455d 100644
    --- a/drivers/power/supply/goldfish_battery.c
    +++ b/drivers/power/supply/goldfish_battery.c
    @@ -224,12 +224,6 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (data->irq < 0)
     		return -ENODEV;
     
    -	ret = devm_request_irq(&pdev->dev, data->irq,
    -			       goldfish_battery_interrupt,
    -			       IRQF_SHARED, pdev->name, data);
    -	if (ret)
    -		return ret;
    -
     	psy_cfg.drv_data = data;
     
     	data->ac = devm_power_supply_register(&pdev->dev,
    @@ -244,6 +238,12 @@ static int goldfish_battery_probe(struct platform_device *pdev)
     	if (IS_ERR(data->battery))
     		return PTR_ERR(data->battery);
     
    +	ret = devm_request_irq(&pdev->dev, data->irq,
    +			       goldfish_battery_interrupt,
    +			       IRQF_SHARED, pdev->name, data);
    +	if (ret)
    +		return ret;
    +
     	GOLDFISH_BATTERY_WRITE(data, BATTERY_INT_ENABLE, BATTERY_INT_MASK);
     	return 0;
     }
    -- 
    cgit 1.3-korg
    
    
    

Vulnerability mechanics

Root cause

"Incorrect ordering of devm-managed resource allocation: IRQ requested before power_supply registration, causing a use-after-free race in the interrupt handler."

Attack vector

An attacker who can trigger device removal (unbind the driver) or cause an interrupt to fire during probe can exploit this use-after-free. During removal, `devm_` deallocates resources in reverse order, so the `power_supply` handle is freed before the IRQ handler is unregistered. An interrupt arriving in that window calls `power_supply_changed()` with a freed handle, causing a crash or memory corruption. Similarly, during probe an interrupt may fire before `power_supply_register()` completes, passing an uninitialized handle to `power_supply_changed()`.

Affected code

The vulnerability is in `drivers/power/supply/goldfish_battery.c` in the `goldfish_battery_probe()` function [patch_id=2661199]. The original code called `devm_request_irq()` before `devm_power_supply_register()`, creating a lifetime ordering problem between the IRQ handler and the power supply handle.

What the fix does

The patch moves `devm_request_irq()` to after both `devm_power_supply_register()` calls (for AC and battery) in `goldfish_battery_probe()` [patch_id=2661199]. This ensures the `power_supply` handle is fully allocated and registered before the IRQ handler can fire. Because `devm_` resources are freed in reverse allocation order, the IRQ handler will now be unregistered before the `power_supply` handle is freed during removal, closing both the removal race and the probe-time race.

Preconditions

  • configThe goldfish battery driver must be loaded and bound to a device
  • inputThe attacker must be able to trigger device removal (e.g., unbind via sysfs) or cause an interrupt to fire during probe

Generated on May 27, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

8

News mentions

0

No linked articles in our index yet.