Skip to content

Commit 55dc449

Browse files
author
Thomas Zimmermann
committed
drm/ast: Handle failed I2C initialization gracefully
I2C initialization is allowed to fail. In this case, create a connector without DDC adapter. The current code would dereference a NULL pointer. Reading the modes from the connector is supposed to work without I2C adapter. Add the respective test. v2: * init edid to NULL to avoid uninitialized read (Dan) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d619f38 commit 55dc449

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,9 +1210,9 @@ static int ast_get_modes(struct drm_connector *connector)
12101210
{
12111211
struct ast_connector *ast_connector = to_ast_connector(connector);
12121212
struct ast_private *ast = to_ast_private(connector->dev);
1213-
struct edid *edid;
1214-
int ret;
1213+
struct edid *edid = NULL;
12151214
bool flags = false;
1215+
int ret;
12161216

12171217
if (ast->tx_chip_type == AST_TX_DP501) {
12181218
ast->dp501_maxclk = 0xff;
@@ -1226,7 +1226,7 @@ static int ast_get_modes(struct drm_connector *connector)
12261226
else
12271227
kfree(edid);
12281228
}
1229-
if (!flags)
1229+
if (!flags && ast_connector->i2c)
12301230
edid = drm_get_edid(connector, &ast_connector->i2c->adapter);
12311231
if (edid) {
12321232
drm_connector_update_edid_property(&ast_connector->base, edid);
@@ -1332,10 +1332,13 @@ static int ast_connector_init(struct drm_device *dev)
13321332
if (!ast_connector->i2c)
13331333
drm_err(dev, "failed to add ddc bus for connector\n");
13341334

1335-
drm_connector_init_with_ddc(dev, connector,
1336-
&ast_connector_funcs,
1337-
DRM_MODE_CONNECTOR_VGA,
1338-
&ast_connector->i2c->adapter);
1335+
if (ast_connector->i2c)
1336+
drm_connector_init_with_ddc(dev, connector, &ast_connector_funcs,
1337+
DRM_MODE_CONNECTOR_VGA,
1338+
&ast_connector->i2c->adapter);
1339+
else
1340+
drm_connector_init(dev, connector, &ast_connector_funcs,
1341+
DRM_MODE_CONNECTOR_VGA);
13391342

13401343
drm_connector_helper_add(connector, &ast_connector_helper_funcs);
13411344

0 commit comments

Comments
 (0)