@@ -203,18 +203,20 @@ static int puv3_i2c_probe(struct platform_device *pdev)
mem->start);
adapter->algo = &puv3_i2c_algorithm;
adapter->class = I2C_CLASS_HWMON;
- adapter->dev.parent = &pdev->dev;
+ adapter->dev.parent = get_device(&pdev->dev);
platform_set_drvdata(pdev, adapter);
adapter->nr = pdev->id;
rc = i2c_add_numbered_adapter(adapter);
if (rc)
- goto fail_add_adapter;
+ goto fail_put_device;
dev_info(&pdev->dev, "PKUnity v3 i2c bus adapter.\n");
return 0;
+fail_put_device:
+ put_device(&pdev->dev);
fail_add_adapter:
kfree(adapter);
fail_nomem:
There is a spurious 'put_device()' in the remove function. A reference to 'pdev->dev' is taken in the probe function without a corresponding 'get_device()' to increment the refcounted reference. Add the missing 'get_device()' and update the error handling path accordingly. Fixes: d10e4a660d11 ("unicore32 machine related files: add i2c bus drivers for pkunity-v3 soc") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- This patch is provided as-is. It is not even compile tested because I don't use cross-compiler. It is purely speculative and based on what looks like an unbalanced 'put_device()' in the remove function. --- drivers/i2c/busses/i2c-puv3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)