of_find_compatible_node() returns a pointer with refcount incremented
so both in the error path as well as after usage in soc_info_populate()
respectively actually b8500_read_soc_id() an explicit of_node_put is
needed to release backupram.

Signed-off-by: Nicholas Mc Guire <hof...@osadl.org>
Fixes: commit 18a992787896 ("ARM: ux500: move soc_id driver to drivers/soc")
---

Problem located with experimental cocinelle script

get_maintainer.pl only returns linux-kernel@vger.kernel.org for
this file ? Is MAINTAINERS entry missing ?

Not really sure about the referenced fixes commit 18a992787896
("ARM: ux500: move soc_id driver to drivers/soc") the commit log notes
only that the driver is being moved and not expected to change (v4.8)
but looking at the previous version in v4.7 it does seem that while
moving the driver there was also a relevant change to the driver code
including the switch to using of_find_compatible_node().

Patch was compiletested with: u8500_defconfig (implies
ONFIG_UX500_SOC_ID=y)

Patch is against 4.18-rc3 (localversion-next is next-20180706)

 drivers/soc/ux500/ux500-soc-id.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/ux500/ux500-soc-id.c b/drivers/soc/ux500/ux500-soc-id.c
index 6c1be74..e22597d 100644
--- a/drivers/soc/ux500/ux500-soc-id.c
+++ b/drivers/soc/ux500/ux500-soc-id.c
@@ -203,10 +203,13 @@ static int __init ux500_soc_device_init(void)
        ux500_setup_id();
 
        soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
-       if (!soc_dev_attr)
+       if (!soc_dev_attr) {
+               of_node_put(backupram);
                return -ENOMEM;
+       }
 
        soc_info_populate(soc_dev_attr, backupram);
+       of_node_put(backupram);
 
        soc_dev = soc_device_register(soc_dev_attr);
        if (IS_ERR(soc_dev)) {
-- 
2.1.4

Reply via email to