Message ID | 20201110013311.2499003-1-yukuai3@huawei.com |
---|---|
State | Deferred |
Headers | show |
Series | [V3] memory: tegra: add missing put_device() call in error path of tegra_emc_probe() | expand |
On Tue, Nov 10, 2020 at 09:33:11AM +0800, Yu Kuai wrote: > The reference to device obtained with of_find_device_by_node() should > be dropped. Thus add jump target to fix the exception handling for this > function implementation. > > Fixes: 73a7f0a90641("memory: tegra: Add EMC (external memory controller) driver") > Signed-off-by: Yu Kuai <yukuai3@huawei.com> > --- > drivers/memory/tegra/tegra124-emc.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) I think you missed my previous comment about the issue being fixed already. Are you sure you rebased this on top of latest next? Best regards, Krzysztof
On 2020/11/10 23:21, Krzysztof Kozlowski wrote: > On Tue, Nov 10, 2020 at 09:33:11AM +0800, Yu Kuai wrote: >> The reference to device obtained with of_find_device_by_node() should >> be dropped. Thus add jump target to fix the exception handling for this >> function implementation. >> >> Fixes: 73a7f0a90641("memory: tegra: Add EMC (external memory controller) driver") >> Signed-off-by: Yu Kuai <yukuai3@huawei.com> >> --- >> drivers/memory/tegra/tegra124-emc.c | 21 +++++++++++++++------ >> 1 file changed, 15 insertions(+), 6 deletions(-) > > I think you missed my previous comment about the issue being fixed > already. Are you sure you rebased this on top of latest next? > Hi, It's true the issue was fixed. Thanks, Yu Kuai > Best regards, > Krzysztof > . >
diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c index 76ace42a688a..7d58a0e0a177 100644 --- a/drivers/memory/tegra/tegra124-emc.c +++ b/drivers/memory/tegra/tegra124-emc.c @@ -1207,8 +1207,10 @@ static int tegra_emc_probe(struct platform_device *pdev) return -ENOENT; emc->mc = platform_get_drvdata(mc); - if (!emc->mc) - return -EPROBE_DEFER; + if (!emc->mc) { + err = -EPROBE_DEFER; + goto put_device; + } ram_code = tegra_read_ram_code(); @@ -1217,25 +1219,27 @@ static int tegra_emc_probe(struct platform_device *pdev) dev_err(&pdev->dev, "no memory timings for RAM code %u found in DT\n", ram_code); - return -ENOENT; + err = -ENOENT; + goto put_device; } err = tegra_emc_load_timings_from_dt(emc, np); of_node_put(np); if (err) - return err; + goto put_device; if (emc->num_timings == 0) { dev_err(&pdev->dev, "no memory timings for RAM code %u registered\n", ram_code); - return -ENOENT; + err = -ENOENT; + goto put_device; } err = emc_init(emc); if (err) { dev_err(&pdev->dev, "EMC initialization failed: %d\n", err); - return err; + goto put_device; } platform_set_drvdata(pdev, emc); @@ -1244,6 +1248,11 @@ static int tegra_emc_probe(struct platform_device *pdev) emc_debugfs_init(&pdev->dev, emc); return 0; + +put_device: + put_device(&mc->dev); + + return err; }; static struct platform_driver tegra_emc_driver = {
The reference to device obtained with of_find_device_by_node() should be dropped. Thus add jump target to fix the exception handling for this function implementation. Fixes: 73a7f0a90641("memory: tegra: Add EMC (external memory controller) driver") Signed-off-by: Yu Kuai <yukuai3@huawei.com> --- drivers/memory/tegra/tegra124-emc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)