FAILED: patch "[PATCH] drm/panel-edp: fix i2c adapter leak on probe failure" failed to apply to 5.15-stable tree
Subsystems (5)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x e2a9e291275a74e309a21cbb1def6296a72d6aed
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090912-bulginess-yearning-759f@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e2a9e291275a74e309a21cbb1def6296a72d6aed Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Fri, 17 Jul 2026 16:31:18 +0200
Subject: [PATCH] drm/panel-edp: fix i2c adapter leak on probe failure
Make sure to drop the i2c adapter reference on probe failure (e.g. probe deferral) and on driver unbind also if a devicetree redundantly uses the 'ddc-i2c-bus' property to point to the aux ddc bus.
drivers/gpu/drm/panel/panel-edp.c +13 -6
@@ -832,6 +832,13 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)return 0 ; } +static void panel_edp_put_adapter (void *_adap) +{ +struct i2c_adapter *adap = _adap; + +put_device (&adap->dev); +} +static int panel_edp_probe (struct device *dev,const struct panel_desc *desc,struct drm_dp_aux *aux) {
@@ -879,6 +886,11 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,if (!panel->ddc)return -EPROBE_DEFER ; + + err =devm_add_action_or_reset (dev, panel_edp_put_adapter, + panel->ddc); +if (err) +return err; }else if (aux) { panel->ddc = &aux->ddc; }
@@ -890,7 +902,7 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, err =drm_panel_of_backlight (&panel->base);if (err) - goto err_finished_ddc_init; +return err;/* * We use runtime PM for prepare / unprepare since those power the panel
@@ -937,9 +949,6 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, err_finished_pm_runtime:pm_runtime_dont_use_autosuspend (dev);pm_runtime_disable (dev); -err_finished_ddc_init: -if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) -put_device (&panel->ddc->dev);return err; }
@@ -983,8 +992,6 @@ static void panel_edp_remove(struct device *dev)pm_runtime_dont_use_autosuspend (dev);pm_runtime_disable (dev); -if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) -put_device (&panel->ddc->dev);drm_edid_free (panel->drm_edid); panel->drm_edid =NULL ;
Sasha Levin
maintainerPATCH 1/2 drm/edid: Break out reading block 0 of the EDID
From: Douglas Anderson <[email protected]>
[ Upstream commit bac9c29482248b00cccfdfef1f34175714d33370 ]
A future change wants to be able to read just block 0 of the EDID, so break it out of drm_do_get_edid() into a sub-function.
This is intended to be a no-op change--just code movement.
Stable-dep-of: e2a9e291275a ("drm/panel-edp: fix i2c adapter leak on probe failure")
--- drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_edid.c +45 -18
@@ -1914,6 +1914,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector) }EXPORT_SYMBOL (drm_add_override_edid_modes); +static struct edid *drm_do_get_edid_base_block ( +int (*get_edid_block)(void *data,u8 *buf,unsigned int block, +size_t len), +void *data,bool *edid_corrupt,int *null_edid_counter) +{ +int i; +void *edid; + + edid =kmalloc (EDID_LENGTH ,GFP_KERNEL ); +if (edid ==NULL ) +return NULL ; + +/* base block fetch */ +for (i =0 ; i <4 ; i++) { +if (get_edid_block (data, edid,0 ,EDID_LENGTH )) + goto out; +if (drm_edid_block_valid (edid,0 , false, edid_corrupt)) +break ; +if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { +if (null_edid_counter) + (*null_edid_counter)++; + goto carp; + } + } +if (i ==4 ) + goto carp; + +return edid; + +carp: +kfree (edid); +return ERR_PTR (-EINVAL ); + +out: +kfree (edid); +return NULL ; +} +/** * drm_do_get_edid - get EDID data using a custom EDID block read function * @connector: connector we're probing
@@ -1947,25 +1985,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,if (override)return override; -if ((edid =kmalloc (EDID_LENGTH ,GFP_KERNEL )) ==NULL ) + edid = (u8 *)drm_do_get_edid_base_block (get_edid_block, data, + &connector->edid_corrupt, + &connector->null_edid_counter); +if (IS_ERR_OR_NULL (edid)) { +if (IS_ERR (edid)) +connector_bad_edid (connector, edid,1 );return NULL ; - -/* base block fetch */ -for (i =0 ; i <4 ; i++) { -if (get_edid_block (data, edid,0 ,EDID_LENGTH )) - goto out; -if (drm_edid_block_valid (edid,0 , false, - &connector->edid_corrupt)) -break ; -if (i ==0 &&drm_edid_is_zero (edid,EDID_LENGTH )) { - connector->null_edid_counter++; - goto carp; - } } -if (i ==4 ) - goto carp; -/* if there's no extensions, we're done */ +/* if there's no extensions or no connector, we're done */ valid_extensions = edid[0x7e ];if (valid_extensions ==0 )return (struct edid *)edid;
@@ -2019,8 +2048,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,return (struct edid *)edid; -carp: -connector_bad_edid (connector, edid,1 ); out:kfree (edid);return NULL ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 drm/panel-edp: fix i2c adapter leak on probe failure
From: Johan Hovold <[email protected]>
[ Upstream commit e2a9e291275a74e309a21cbb1def6296a72d6aed ]
Make sure to drop the i2c adapter reference on probe failure (e.g. probe deferral) and on driver unbind also if a devicetree redundantly uses the 'ddc-i2c-bus' property to point to the aux ddc bus.
--- drivers/gpu/drm/panel/panel-simple.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +4 -2
@@ -187,6 +187,7 @@ struct panel_simple {struct regulator *supply;struct i2c_adapter *ddc; +bool ddc_ref;struct drm_dp_aux *aux;struct gpio_desc *enable_gpio;
@@ -712,6 +713,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc,if (!panel->ddc)return -EPROBE_DEFER ; + panel->ddc_ref = true; }else if (aux) { panel->ddc = &aux->ddc; }
@@ -816,7 +818,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc,pm_runtime_dont_use_autosuspend (dev);pm_runtime_disable (dev); free_ddc: -if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) +if (panel->ddc_ref)put_device (&panel->ddc->dev);return err;
@@ -832,7 +834,7 @@ static int panel_simple_remove(struct device *dev)pm_runtime_dont_use_autosuspend (dev);pm_runtime_disable (dev); -if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) +if (panel->ddc_ref)put_device (&panel->ddc->dev);return 0 ;
Signature · 1 line
2.53.0