Re: [PATCH 07/10] ASoC: cs42l42: Split I2C identity into separate module

From: Martin Povišer
Date: Fri Sep 09 2022 - 11:44:24 EST



> On 9. 9. 2022, at 17:40, Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> On 09/09/2022 14:53, Martin Povišer wrote:
>> +static int cs42l42_i2c_probe(struct i2c_client *i2c_client)
>> +{
>> + struct device *dev = &i2c_client->dev;
>> + struct cs42l42_private *cs42l42;
>> + struct regmap *regmap;
>> + int ret;
>> +
>> + cs42l42 = devm_kzalloc(dev, sizeof(*cs42l42), GFP_KERNEL);
>> + if (!cs42l42)
>> + return -ENOMEM;
>> +
>> + regmap = devm_regmap_init_i2c(i2c_client, &cs42l42_regmap);
>> + if (IS_ERR(regmap)) {
>> + ret = PTR_ERR(regmap);
>> + dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + cs42l42->dev = dev;
>> + cs42l42->regmap = regmap;
>> + cs42l42->irq = i2c_client->irq;
>> +
>> + ret = cs42l42_common_probe(cs42l42, &cs42l42_soc_component, &cs42l42_dai);
>> + if (ret)
>> + return ret;
>> +
>> + ret = cs42l42_init(cs42l42);
>> + if (ret)
>> + cs42l42_common_remove(cs42l42);
>
> This introduces a bug that regulator_bulk_disable() is called
> twice if there is an error.
>
> cs42l42_init() was supposed to clean up if it returns an error, which
> it nearly does, but my original patch is missing the call to free_irq()
> in the error paths of cs42l42_init().

Ah! I didn’t inspect it closely enough then, I only ran into the missing
free_irq.

Martin