From: Matthias Brugger <matthias.bgg@gmail.com>
To: Daniel Kurtz <djkurtz@chromium.org>,
Hongzhou Yang <hongzhou.yang@mediatek.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Axel Lin <axel.lin@ingics.com>,
Maoguang Meng <maoguang.meng@mediatek.com>,
Colin Ian King <colin.king@canonical.com>,
linux-gpio@vger.kernel.org,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
linux-mediatek@lists.infradead.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
srv_heupstream <srv_heupstream@mediatek.com>,
Sascha Hauer <kernel@pengutronix.de>,
biao.huang@mediatek.com
Subject: Re: [PATCH] pinctrl: mediatek: fix a memleak when do dt maps.
Date: Tue, 17 Nov 2015 11:50:38 +0100 [thread overview]
Message-ID: <564B067E.2010000@gmail.com> (raw)
In-Reply-To: <CAGS+omCiaD-JJdvL77Y4HuvWjgC5tvLDLspsAgXPtD5AP3JA7w@mail.gmail.com>
On 17/11/15 09:25, Daniel Kurtz wrote:
> On Tue, Nov 17, 2015 at 12:22 PM, Hongzhou Yang
> <hongzhou.yang@mediatek.com> wrote:
>> configs will kmemdup to dup_configs in pictrl util function.
>> So configs need to be freed.
>>
>> Signed-off-by: Hongzhou Yang <hongzhou.yang@mediatek.com>
>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
>
>> ---
>> Fix a memleak issue.
>>
>> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 24 ++++++++++++++----------
>> 1 file changed, 14 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> index bbf0230..0f9e416 100644
>> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> @@ -520,21 +520,23 @@ static int mtk_pctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
>> if (has_config && num_pins >= 1)
>> maps_per_pin++;
>>
>> - if (!num_pins || !maps_per_pin)
>> - return -EINVAL;
>> + if (!num_pins || !maps_per_pin) {
>> + err = -EINVAL;
>> + goto exit;
>> + }
>>
>> reserve = num_pins * maps_per_pin;
>>
>> err = pinctrl_utils_reserve_map(pctldev, map,
>> reserved_maps, num_maps, reserve);
>> if (err < 0)
>> - goto fail;
>> + goto exit;
>>
>> for (i = 0; i < num_pins; i++) {
>> err = of_property_read_u32_index(node, "pinmux",
>> i, &pinfunc);
>> if (err)
>> - goto fail;
>> + goto exit;
>>
>> pin = MTK_GET_PIN_NO(pinfunc);
>> func = MTK_GET_PIN_FUNC(pinfunc);
>> @@ -543,20 +545,21 @@ static int mtk_pctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
>> func >= ARRAY_SIZE(mtk_gpio_functions)) {
>> dev_err(pctl->dev, "invalid pins value.\n");
>> err = -EINVAL;
>> - goto fail;
>> + goto exit;
>> }
>>
>> grp = mtk_pctrl_find_group_by_pin(pctl, pin);
>> if (!grp) {
>> dev_err(pctl->dev, "unable to match pin %d to group\n",
>> pin);
>> - return -EINVAL;
>> + err = -EINVAL;
>> + goto exit;
>> }
>>
>> err = mtk_pctrl_dt_node_to_map_func(pctl, pin, func, grp, map,
>> reserved_maps, num_maps);
>> if (err < 0)
>> - goto fail;
>> + goto exit;
>>
>> if (has_config) {
>> err = pinctrl_utils_add_map_configs(pctldev, map,
>> @@ -564,13 +567,14 @@ static int mtk_pctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
>> configs, num_configs,
>> PIN_MAP_TYPE_CONFIGS_GROUP);
>> if (err < 0)
>> - goto fail;
>> + goto exit;
>> }
>> }
>>
>> - return 0;
>> + err = 0;
>>
>> -fail:
>> +exit:
>> + kfree(configs);
>> return err;
>> }
>>
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2015-11-17 10:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 4:22 [PATCH] pinctrl: mediatek: fix a memleak when do dt maps Hongzhou Yang
2015-11-17 8:25 ` Daniel Kurtz
2015-11-17 10:50 ` Matthias Brugger [this message]
2015-11-17 14:18 ` Yingjoe Chen
-- strict thread matches above, loose matches on Subject: below --
2015-11-17 22:33 Hongzhou Yang
2015-11-18 3:22 ` Yingjoe Chen
2015-11-29 21:35 ` Linus Walleij
2015-11-17 2:34 Hongzhou Yang
2015-11-17 2:50 ` Daniel Kurtz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=564B067E.2010000@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=axel.lin@ingics.com \
--cc=biao.huang@mediatek.com \
--cc=colin.king@canonical.com \
--cc=djkurtz@chromium.org \
--cc=hongzhou.yang@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=maoguang.meng@mediatek.com \
--cc=srv_heupstream@mediatek.com \
--cc=yingjoe.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).