Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a765c3f authored by Russell King's avatar Russell King
Browse files

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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent d93ae190
Loading
Loading
Loading
Loading
+18 −13
Original line number Original line Diff line number Diff line
@@ -1501,10 +1501,15 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)


	/* read version: */
	/* read version: */
	rev_lo = reg_read(priv, REG_VERSION_LSB);
	rev_lo = reg_read(priv, REG_VERSION_LSB);
	if (rev_lo < 0) {
		dev_err(&client->dev, "failed to read version: %d\n", rev_lo);
		return rev_lo;
	}

	rev_hi = reg_read(priv, REG_VERSION_MSB);
	rev_hi = reg_read(priv, REG_VERSION_MSB);
	if (rev_lo < 0 || rev_hi < 0) {
	if (rev_hi < 0) {
		ret = rev_lo < 0 ? rev_lo : rev_hi;
		dev_err(&client->dev, "failed to read version: %d\n", rev_hi);
		goto fail;
		return rev_hi;
	}
	}


	priv->rev = rev_lo | rev_hi << 8;
	priv->rev = rev_lo | rev_hi << 8;
@@ -1528,7 +1533,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
	default:
	default:
		dev_err(&client->dev, "found unsupported device: %04x\n",
		dev_err(&client->dev, "found unsupported device: %04x\n",
			priv->rev);
			priv->rev);
		goto fail;
		return -ENXIO;
	}
	}


	/* after reset, enable DDC: */
	/* after reset, enable DDC: */
@@ -1566,7 +1571,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
			dev_err(&client->dev,
			dev_err(&client->dev,
				"failed to request IRQ#%u: %d\n",
				"failed to request IRQ#%u: %d\n",
				client->irq, ret);
				client->irq, ret);
			goto fail;
			goto err_irq;
		}
		}


		/* enable HPD irq */
		/* enable HPD irq */
@@ -1589,19 +1594,19 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)


	ret = tda998x_get_audio_ports(priv, np);
	ret = tda998x_get_audio_ports(priv, np);
	if (ret)
	if (ret)
		goto fail;
		goto err_audio;


	if (priv->audio_port[0].format != AFMT_UNUSED)
	if (priv->audio_port[0].format != AFMT_UNUSED)
		tda998x_audio_codec_init(priv, &client->dev);
		tda998x_audio_codec_init(priv, &client->dev);


	return 0;
	return 0;
fail:

	/* if encoder_init fails, the encoder slave is never registered,
err_audio:
	 * so cleanup here:
	if (client->irq)
	 */
		free_irq(client->irq, priv);
	if (priv->cec)
err_irq:
	i2c_unregister_device(priv->cec);
	i2c_unregister_device(priv->cec);
	return -ENXIO;
	return ret;
}
}


static void tda998x_encoder_prepare(struct drm_encoder *encoder)
static void tda998x_encoder_prepare(struct drm_encoder *encoder)