Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/bridge_connector: Handle drm_connector_init_with_ddc() failures

drm_connector_init_with_ddc() can fail, but the call in
drm_bridge_connector_init() does not check that. Fix this by adding
the missing error handling.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/3a7e9540d8dc94298d021aa2fb046ae8616ca4dd.1689599701.git.geert+renesas@glider.be

authored by

Geert Uytterhoeven and committed by
Javier Martinez Canillas
d0b4c1cf cc4adf3a

+9 -2
+9 -2
drivers/gpu/drm/drm_bridge_connector.c
··· 318 318 struct i2c_adapter *ddc = NULL; 319 319 struct drm_bridge *bridge, *panel_bridge = NULL; 320 320 int connector_type; 321 + int ret; 321 322 322 323 bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); 323 324 if (!bridge_connector) ··· 369 368 return ERR_PTR(-EINVAL); 370 369 } 371 370 372 - drm_connector_init_with_ddc(drm, connector, &drm_bridge_connector_funcs, 373 - connector_type, ddc); 371 + ret = drm_connector_init_with_ddc(drm, connector, 372 + &drm_bridge_connector_funcs, 373 + connector_type, ddc); 374 + if (ret) { 375 + kfree(bridge_connector); 376 + return ERR_PTR(ret); 377 + } 378 + 374 379 drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs); 375 380 376 381 if (bridge_connector->bridge_hpd)