Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544329

[RFC] Question about freeing of resource in 'atlas7_pinmux_probe()', in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c'

Path csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Newsgroups linux.kernel
Subject [RFC] Question about freeing of resource in 'atlas7_pinmux_probe()', in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c'
Date Mon, 19 Dec 2016 07:30:01 +0100
Message-ID <sPZCp-49P-3@gated-at.bofh.it> (permalink)
X-Original-To linus.walleij@linaro.org, baohua@kernel.org
X-Me-Helo [127.0.0.1]
X-Me-Date Mon, 19 Dec 2016 07:19:53 +0100
X-Me-IP 92.140.239.141
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1
MIME-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Antivirus avast! (VPS 161218-0, 18/12/2016), Outbound message
X-Antivirus-Status Clean
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 53
Organization linux.* mail to news gateway
X-Original-Cc linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
X-Original-Date Mon, 19 Dec 2016 07:19:43 +0100
X-Original-Message-ID <612eedc5-0f28-7a38-abad-4b9573208875@wanadoo.fr>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1544329

Show key headers only | View raw


Hi,

while playing with coccinelle, a missing 'of_node_put()' triggered in 
'atlas7_pinmux_probe()', in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c'.

     /* The sd3 and sd9 shared all pins, and the function select by
      * SYS2PCI_SDIO9SEL register
      */
     sys2pci_np = of_find_node_by_name(NULL, "sys2pci");
     if (!sys2pci_np)
         return -EINVAL;
     ret = of_address_to_resource(sys2pci_np, 0, &res);
     if (ret) <-------------    missing of_node_put(sys2pci_np);
         return ret;
     pmx->sys2pci_base = devm_ioremap_resource(&pdev->dev, &res);
     if (IS_ERR(pmx->sys2pci_base)) {
         of_node_put(sys2pci_np); <-------------    added by commit 
151b8c5ba1eb
         return -ENOMEM;
     }

Looking at the history of this file, I found a recent commit that added 
another missing of_node_put (see above).


Adding missing 'of_node_put()' in error handling paths is fine, but in 
this particular case, I was wondering if one was not also missing in the 
normal path?


In such a case, I would revert 151b8c5ba1eb and propose something like:
     /* The sd3 and sd9 shared all pins, and the function select by
      * SYS2PCI_SDIO9SEL register
      */
     sys2pci_np = of_find_node_by_name(NULL, "sys2pci");
     if (!sys2pci_np)
         return -EINVAL;
     ret = of_address_to_resource(sys2pci_np, 0, &res);
     if (ret) {
         of_node_put(sys2pci_np);
         return ret;
     }
     of_node_put(sys2pci_np);

     pmx->sys2pci_base = devm_ioremap_resource(&pdev->dev, &res);
     if (IS_ERR(pmx->sys2pci_base))
         return -ENOMEM;

Thanks for your comment,

best regards,

CJ

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[RFC] Question about freeing of resource in 'atlas7_pinmux_probe()',  in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c' Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-12-19 07:30 +0100
  Re: [RFC] Question about freeing of resource in  'atlas7_pinmux_probe()', in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c' Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> - 2016-12-19 15:00 +0100
    Re: [RFC] Question about freeing of resource in  'atlas7_pinmux_probe()', in file 'drivers/pinctrl/sirf/pinctrl-atlas7.c' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-12-20 06:50 +0100

csiph-web