lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGS+omAE2AXpwnYtvetcjvP_6jUbE2HDuPfKfy=aLook2M-8LQ@mail.gmail.com>
Date:	Tue, 11 Aug 2015 15:45:21 +0800
From:	Daniel Kurtz <djkurtz@...omium.org>
To:	Hongzhou Yang <hongzhou.yang@...iatek.com>
Cc:	Linus Walleij <linus.walleij@...aro.org>,
	Matthias Brugger <matthias.bgg@...il.com>,
	Maoguang Meng <maoguang.meng@...iatek.com>,
	Axel Lin <axel.lin@...ics.com>, linux-gpio@...r.kernel.org,
	Antoine Tenart <antoine.tenart@...e-electrons.com>,
	Eddie Huang (黃智傑) 
	<eddie.huang@...iatek.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Masahiro Yamada <yamada.masahiro@...ionext.com>,
	linux-mediatek@...ts.infradead.org,
	Sascha Hauer <kernel@...gutronix.de>,
	Yingjoe Chen <yingjoe.chen@...iatek.com>,
	biao.huang@...iatek.com, dandan.he@...iatek.com,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] pinctrl: mediatek: Fix multiple registeration issue.

On Tue, Aug 11, 2015 at 12:49 PM, Hongzhou Yang
<hongzhou.yang@...iatek.com> wrote:
> Use dynamic allocation to fix multiple registeration issue.

s/registeration/registration   - here and in the patch subject.

>
> --------------8<--------------------

I don't think this is required.

> Since our common driver need support main chip and PMU
> at the same time, that means it will register two
> pinctrl device, and the pinctrl_desc structure should
> be used two times.
>
> But pinctrl_desc use global static definition, then
> the latest registered pinctrl device will overwrite
> the old one's, all members in pinctrl_desc will set to
> the new one's, such as name, pins and pins numbers, etc.
> This is a bug. Changing to use devm_kzalloc to fix it.
>
> Cc: stable@...r.kernel.org # v4.1+
> Signed-off-by: Hongzhou Yang <hongzhou.yang@...iatek.com>
> ---
>  drivers/pinctrl/mediatek/pinctrl-mtk-common.c |   27 +++++++++++++++----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index ad1ea16..2bba504 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -1202,17 +1202,12 @@ static int mtk_pctrl_build_state(struct platform_device *pdev)
>         return 0;
>  }
>
> -static struct pinctrl_desc mtk_pctrl_desc = {
> -       .confops        = &mtk_pconf_ops,
> -       .pctlops        = &mtk_pctrl_ops,
> -       .pmxops         = &mtk_pmx_ops,
> -};
> -
>  int mtk_pctrl_init(struct platform_device *pdev,
>                 const struct mtk_pinctrl_devdata *data,
>                 struct regmap *regmap)
>  {
>         struct pinctrl_pin_desc *pins;
> +       struct pinctrl_desc *mtk_pctrl_desc;
>         struct mtk_pinctrl *pctl;
>         struct device_node *np = pdev->dev.of_node, *node;
>         struct property *prop;
> @@ -1265,12 +1260,22 @@ int mtk_pctrl_init(struct platform_device *pdev,
>
>         for (i = 0; i < pctl->devdata->npins; i++)
>                 pins[i] = pctl->devdata->pins[i].pin;
> -       mtk_pctrl_desc.name = dev_name(&pdev->dev);
> -       mtk_pctrl_desc.owner = THIS_MODULE;
> -       mtk_pctrl_desc.pins = pins;
> -       mtk_pctrl_desc.npins = pctl->devdata->npins;
> +
> +       mtk_pctrl_desc = devm_kzalloc(&pdev->dev, sizeof(*mtk_pctrl_desc),
> +                               GFP_KERNEL);
> +       if (!mtk_pctrl_desc)
> +               return -ENOMEM;

Just embed a struct pinctrl_desc in your struct mtk_pinctrl.

Best Regards,
-Dan

> +
> +       mtk_pctrl_desc->name = dev_name(&pdev->dev);
> +       mtk_pctrl_desc->owner = THIS_MODULE;
> +       mtk_pctrl_desc->pins = pins;
> +       mtk_pctrl_desc->npins = pctl->devdata->npins;
> +       mtk_pctrl_desc->confops = &mtk_pconf_ops;
> +       mtk_pctrl_desc->pctlops = &mtk_pctrl_ops;
> +       mtk_pctrl_desc->pmxops = &mtk_pmx_ops;
>         pctl->dev = &pdev->dev;
> -       pctl->pctl_dev = pinctrl_register(&mtk_pctrl_desc, &pdev->dev, pctl);
> +
> +       pctl->pctl_dev = pinctrl_register(mtk_pctrl_desc, &pdev->dev, pctl);
>         if (IS_ERR(pctl->pctl_dev)) {
>                 dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
>                 return PTR_ERR(pctl->pctl_dev);
> --
> 1.7.9.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ