On the SSD1307 variant, ssd1307fb_init() gets and enables the PWM
before it sends the panel init commands over I2C. If one of those
writes fails, ssd1307fb_probe() jumps to regulator_enable_error, below
the pwm_disable()/pwm_put() at panel_init_error. The PWM is left
enabled and requested, and its references on the PWM chip device and
module are never dropped. As the PWM stays marked as requested, a later
probe of the display can no longer get it (pwm_device_request() returns
-EBUSY).

The sashiko AI review bot pointed this out on 2026-09-26, while
reviewing an unrelated ssd1307fb error-handling patch.

Jump to panel_init_error instead and drop the now unused
regulator_enable_error label. pwm_disable() and pwm_put() accept NULL,
which covers variants without a PWM, so clear par->pwm when pwm_get()
fails instead of leaving an ERR_PTR() for the error path.

Fixes: bbc79089ae2b ("video: ssd1307fb: Add support for SSD1306 OLED 
controller")
Cc: [email protected]
Link: 
https://sashiko.dev/#/patchset/20260926-fix-fbdefio-error-handling-v1-0-a94810b6e263%40kernel.org
Signed-off-by: Yige Jiang <[email protected]>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_FB_SSD1307=m, CONFIG_PWM=y, 
CONFIG_COMPILE_TEST=y; baseline and patched ssd1307fb.o, no new warnings.
No hardware or runtime test was performed.
The path needs an I2C write error during panel init on a solomon,ssd1307fb-i2c 
device.

 drivers/video/fbdev/ssd1307fb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index ef4bb920c6ff..dbe5dc67e044 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -403,7 +403,9 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
                par->pwm = pwm_get(&par->client->dev, NULL);
                if (IS_ERR(par->pwm)) {
                        dev_err(&par->client->dev, "Could not get PWM from 
device tree!\n");
-                       return PTR_ERR(par->pwm);
+                       ret = PTR_ERR(par->pwm);
+                       par->pwm = NULL;
+                       return ret;
                }
 
                pwm_init_state(par->pwm, &pwmstate);
@@ -794,7 +796,7 @@ static int ssd1307fb_probe(struct i2c_client *client)
 
        ret = ssd1307fb_init(par);
        if (ret)
-               goto regulator_enable_error;
+               goto panel_init_error;
 
        bl = backlight_device_register("ssd1307fb-bl", dev, par, 
&ssd1307fb_bl_ops,
                                       NULL);
@@ -823,7 +825,6 @@ static int ssd1307fb_probe(struct i2c_client *client)
 panel_init_error:
        pwm_disable(par->pwm);
        pwm_put(par->pwm);
-regulator_enable_error:
        if (par->vbat_reg)
                regulator_disable(par->vbat_reg);
 reset_oled_error:

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

Reply via email to