aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2016-11-17 18:49:43 -0500
committerRussell King <rmk+kernel@armlinux.org.uk>2018-04-03 07:21:54 -0400
commit6a765c3fe5497359c11536dfbdcf7526ccb2a33f (patch)
tree1085f03e2b884648829fe80675b006553df3f23e
parentd93ae190e2c95276caceb3642e6d541d93bba705 (diff)
drm/i2c: tda998x: fix error cleanup paths
If tda998x_get_audio_ports() fails, and we requested the interrupt, we fail to free the interrupt before returning failure. Rework the failure cleanup code and exit paths so that we always clean up properly after an error, and always propagate the error code. Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/gpu/drm/i2c/tda998x_drv.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index 83407159e957..2a99930f1bda 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1501,10 +1501,15 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
1501 1501
1502 /* read version: */ 1502 /* read version: */
1503 rev_lo = reg_read(priv, REG_VERSION_LSB); 1503 rev_lo = reg_read(priv, REG_VERSION_LSB);
1504 if (rev_lo < 0) {
1505 dev_err(&client->dev, "failed to read version: %d\n", rev_lo);
1506 return rev_lo;
1507 }
1508
1504 rev_hi = reg_read(priv, REG_VERSION_MSB); 1509 rev_hi = reg_read(priv, REG_VERSION_MSB);
1505 if (rev_lo < 0 || rev_hi < 0) { 1510 if (rev_hi < 0) {
1506 ret = rev_lo < 0 ? rev_lo : rev_hi; 1511 dev_err(&client->dev, "failed to read version: %d\n", rev_hi);
1507 goto fail; 1512 return rev_hi;
1508 } 1513 }
1509 1514
1510 priv->rev = rev_lo | rev_hi << 8; 1515 priv->rev = rev_lo | rev_hi << 8;
@@ -1528,7 +1533,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
1528 default: 1533 default:
1529 dev_err(&client->dev, "found unsupported device: %04x\n", 1534 dev_err(&client->dev, "found unsupported device: %04x\n",
1530 priv->rev); 1535 priv->rev);
1531 goto fail; 1536 return -ENXIO;
1532 } 1537 }
1533 1538
1534 /* after reset, enable DDC: */ 1539 /* after reset, enable DDC: */
@@ -1566,7 +1571,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
1566 dev_err(&client->dev, 1571 dev_err(&client->dev,
1567 "failed to request IRQ#%u: %d\n", 1572 "failed to request IRQ#%u: %d\n",
1568 client->irq, ret); 1573 client->irq, ret);
1569 goto fail; 1574 goto err_irq;
1570 } 1575 }
1571 1576
1572 /* enable HPD irq */ 1577 /* enable HPD irq */
@@ -1589,19 +1594,19 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
1589 1594
1590 ret = tda998x_get_audio_ports(priv, np); 1595 ret = tda998x_get_audio_ports(priv, np);
1591 if (ret) 1596 if (ret)
1592 goto fail; 1597 goto err_audio;
1593 1598
1594 if (priv->audio_port[0].format != AFMT_UNUSED) 1599 if (priv->audio_port[0].format != AFMT_UNUSED)
1595 tda998x_audio_codec_init(priv, &client->dev); 1600 tda998x_audio_codec_init(priv, &client->dev);
1596 1601
1597 return 0; 1602 return 0;
1598fail: 1603
1599 /* if encoder_init fails, the encoder slave is never registered, 1604err_audio:
1600 * so cleanup here: 1605 if (client->irq)
1601 */ 1606 free_irq(client->irq, priv);
1602 if (priv->cec) 1607err_irq:
1603 i2c_unregister_device(priv->cec); 1608 i2c_unregister_device(priv->cec);
1604 return -ENXIO; 1609 return ret;
1605} 1610}
1606 1611
1607static void tda998x_encoder_prepare(struct drm_encoder *encoder) 1612static void tda998x_encoder_prepare(struct drm_encoder *encoder)