Skip to content

Commit 20c4760

Browse files
Benjamin-Gaignardvinceab
authored andcommitted
drm/sti: fix potential crash in gdp
In some cases last_close() could be called before sti_gdp_disable() and make kernel crash because mixer structure has been destroy. Let's gdp keep a reference on vtg to fix that (like it is already done in HQVDP) Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Reviewed-by: Vincent Abriou <vincent.abriou@st.com>
1 parent 44ab404 commit 20c4760

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/gpu/drm/sti/sti_gdp.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct sti_gdp_node_list {
9797
* @vtg_field_nb: callback for VTG FIELD (top or bottom) notification
9898
* @is_curr_top: true if the current node processed is the top field
9999
* @node_list: array of node list
100+
* @vtg: registered vtg
100101
*/
101102
struct sti_gdp {
102103
struct sti_plane plane;
@@ -108,6 +109,7 @@ struct sti_gdp {
108109
struct notifier_block vtg_field_nb;
109110
bool is_curr_top;
110111
struct sti_gdp_node_list node_list[GDP_NODE_NB_BANK];
112+
struct sti_vtg *vtg;
111113
};
112114

113115
#define to_sti_gdp(x) container_of(x, struct sti_gdp, plane)
@@ -240,9 +242,6 @@ struct sti_gdp_node_list *sti_gdp_get_current_nodes(struct sti_gdp *gdp)
240242
*/
241243
static void sti_gdp_disable(struct sti_gdp *gdp)
242244
{
243-
struct drm_plane *drm_plane = &gdp->plane.drm_plane;
244-
struct sti_mixer *mixer = to_sti_mixer(drm_plane->crtc);
245-
struct sti_compositor *compo = dev_get_drvdata(gdp->dev);
246245
unsigned int i;
247246

248247
DRM_DEBUG_DRIVER("%s\n", sti_plane_to_str(&gdp->plane));
@@ -253,8 +252,7 @@ static void sti_gdp_disable(struct sti_gdp *gdp)
253252
gdp->node_list[i].btm_field->gam_gdp_ppt |= GAM_GDP_PPT_IGNORE;
254253
}
255254

256-
if (sti_vtg_unregister_client(mixer->id == STI_MIXER_MAIN ?
257-
compo->vtg_main : compo->vtg_aux, &gdp->vtg_field_nb))
255+
if (sti_vtg_unregister_client(gdp->vtg, &gdp->vtg_field_nb))
258256
DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n");
259257

260258
if (gdp->clk_pix)
@@ -490,7 +488,10 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
490488

491489
if (first_prepare) {
492490
/* Register gdp callback */
493-
if (sti_vtg_register_client(mixer->id == STI_MIXER_MAIN ?
491+
gdp->vtg = mixer->id == STI_MIXER_MAIN ?
492+
compo->vtg_main : compo->vtg_aux;
493+
494+
if (sti_vtg_register_client(gdp->vtg == STI_MIXER_MAIN ?
494495
compo->vtg_main : compo->vtg_aux,
495496
&gdp->vtg_field_nb, crtc)) {
496497
DRM_ERROR("Cannot register VTG notifier\n");

0 commit comments

Comments
 (0)