[RESEND PATCH v2 2/5] backlight: pwm_bl: Add device link for pwm_bl and pwm

From: Jeffy Chen
Date: Mon Oct 16 2017 - 06:07:28 EST


When the pwm driver is unbound, the pwm_bl driver would still hold a
reference to that pwm, and crash the kernel later(if someone trying
to access that invalid pwm).

Add a device link to avoid this.

Signed-off-by: Jeffy Chen <jeffy.chen@xxxxxxxxxxxxxx>
---

Changes in v2: None

drivers/video/backlight/pwm_bl.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 9bd17682655a..a76f147a26e7 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -328,6 +328,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
goto err_alloc;
}

+ device_link_add(&pdev->dev, pb->pwm->chip->dev, DL_FLAG_AUTOREMOVE);
+
dev_dbg(&pdev->dev, "got pwm for backlight\n");

/*
--
2.11.0