2022-06-29 16:20:38

by Hsin-Yi Wang

[permalink] [raw]
Subject: [PATCH 3/4] drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel

Move devm_of_dp_aux_populate_ep_devices() after pm runtime and i2c setup
to avoid NULL pointer crash.

edp-panel probe (generic_edp_panel_probe) calls pm_runtime_get_sync() to
read EDID. At this time, bridge should have pm runtime enabled and i2c
clients ready.

Fixes: adca62ec370c ("drm/bridge: anx7625: Support reading edid through aux channel")
Signed-off-by: Hsin-Yi Wang <[email protected]>
---
drivers/gpu/drm/bridge/analogix/anx7625.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 478f5af381c7d..59ddeba33652b 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -2590,14 +2590,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
platform->aux.dev = dev;
platform->aux.transfer = anx7625_aux_transfer;
drm_dp_aux_init(&platform->aux);
- devm_of_dp_aux_populate_ep_devices(&platform->aux);
-
- ret = anx7625_parse_dt(dev, pdata);
- if (ret) {
- if (ret != -EPROBE_DEFER)
- DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
- goto free_wq;
- }

if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
ret = -ENOMEM;
@@ -2613,6 +2605,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,
if (ret)
goto free_wq;

+ devm_of_dp_aux_populate_ep_devices(&platform->aux);
+
+ ret = anx7625_parse_dt(dev, pdata);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
+ goto free_wq;
+ }
+
if (!platform->pdata.low_power_mode) {
anx7625_disable_pd_protocol(platform);
pm_runtime_get_sync(dev);
--
2.37.0.rc0.161.g10f37bed90-goog


2022-07-06 02:53:22

by Xin Ji

[permalink] [raw]
Subject: Re: [PATCH 3/4] drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel

Hi Hsin-Yi, thanks for your patch, it looks good to me.

Reviewed-by: Xin Ji <[email protected]>

Thanks,
Xin

On Thu, Jun 30, 2022 at 12:05:49AM +0800, Hsin-Yi Wang wrote:
> Move devm_of_dp_aux_populate_ep_devices() after pm runtime and i2c setup
> to avoid NULL pointer crash.
>
> edp-panel probe (generic_edp_panel_probe) calls pm_runtime_get_sync() to
> read EDID. At this time, bridge should have pm runtime enabled and i2c
> clients ready.
>
> Fixes: adca62ec370c ("drm/bridge: anx7625: Support reading edid through aux channel")
> Signed-off-by: Hsin-Yi Wang <[email protected]>
> ---
> drivers/gpu/drm/bridge/analogix/anx7625.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 478f5af381c7d..59ddeba33652b 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -2590,14 +2590,6 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> platform->aux.dev = dev;
> platform->aux.transfer = anx7625_aux_transfer;
> drm_dp_aux_init(&platform->aux);
> - devm_of_dp_aux_populate_ep_devices(&platform->aux);
> -
> - ret = anx7625_parse_dt(dev, pdata);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
> - goto free_wq;
> - }
>
> if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
> ret = -ENOMEM;
> @@ -2613,6 +2605,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,
> if (ret)
> goto free_wq;
>
> + devm_of_dp_aux_populate_ep_devices(&platform->aux);
> +
> + ret = anx7625_parse_dt(dev, pdata);
> + if (ret) {
> + if (ret != -EPROBE_DEFER)
> + DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
> + goto free_wq;
> + }
> +
> if (!platform->pdata.low_power_mode) {
> anx7625_disable_pd_protocol(platform);
> pm_runtime_get_sync(dev);
> --
> 2.37.0.rc0.161.g10f37bed90-goog