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 <tzimmermann@suse.de> Reviewed-by: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20211206091125.29501-2-tzimmermann@suse.de
This commit is contained in:
parent
d619f38c01
commit
55dc449a7c
|
@ -1210,9 +1210,9 @@ static int ast_get_modes(struct drm_connector *connector)
|
||||||
{
|
{
|
||||||
struct ast_connector *ast_connector = to_ast_connector(connector);
|
struct ast_connector *ast_connector = to_ast_connector(connector);
|
||||||
struct ast_private *ast = to_ast_private(connector->dev);
|
struct ast_private *ast = to_ast_private(connector->dev);
|
||||||
struct edid *edid;
|
struct edid *edid = NULL;
|
||||||
int ret;
|
|
||||||
bool flags = false;
|
bool flags = false;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (ast->tx_chip_type == AST_TX_DP501) {
|
if (ast->tx_chip_type == AST_TX_DP501) {
|
||||||
ast->dp501_maxclk = 0xff;
|
ast->dp501_maxclk = 0xff;
|
||||||
|
@ -1226,7 +1226,7 @@ static int ast_get_modes(struct drm_connector *connector)
|
||||||
else
|
else
|
||||||
kfree(edid);
|
kfree(edid);
|
||||||
}
|
}
|
||||||
if (!flags)
|
if (!flags && ast_connector->i2c)
|
||||||
edid = drm_get_edid(connector, &ast_connector->i2c->adapter);
|
edid = drm_get_edid(connector, &ast_connector->i2c->adapter);
|
||||||
if (edid) {
|
if (edid) {
|
||||||
drm_connector_update_edid_property(&ast_connector->base, edid);
|
drm_connector_update_edid_property(&ast_connector->base, edid);
|
||||||
|
@ -1332,10 +1332,13 @@ static int ast_connector_init(struct drm_device *dev)
|
||||||
if (!ast_connector->i2c)
|
if (!ast_connector->i2c)
|
||||||
drm_err(dev, "failed to add ddc bus for connector\n");
|
drm_err(dev, "failed to add ddc bus for connector\n");
|
||||||
|
|
||||||
drm_connector_init_with_ddc(dev, connector,
|
if (ast_connector->i2c)
|
||||||
&ast_connector_funcs,
|
drm_connector_init_with_ddc(dev, connector, &ast_connector_funcs,
|
||||||
DRM_MODE_CONNECTOR_VGA,
|
DRM_MODE_CONNECTOR_VGA,
|
||||||
&ast_connector->i2c->adapter);
|
&ast_connector->i2c->adapter);
|
||||||
|
else
|
||||||
|
drm_connector_init(dev, connector, &ast_connector_funcs,
|
||||||
|
DRM_MODE_CONNECTOR_VGA);
|
||||||
|
|
||||||
drm_connector_helper_add(connector, &ast_connector_helper_funcs);
|
drm_connector_helper_add(connector, &ast_connector_helper_funcs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue