From: Martin Kaiser <martin@kaiser.cx>
To: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>,
Fabio Estevam <festevam@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Shawn Guo <shawnguo@kernel.org>, Stefan Agner <stefan@agner.ch>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH] pinctrl: imx: make sure that maps are fully initialized
Date: Mon, 12 Nov 2018 16:37:21 +0100 [thread overview]
Message-ID: <20181112153721.ekgpql3pj3bbv6ee@viti.kaiser.cx> (raw)
In-Reply-To: <AM0PR04MB4290D734ED5D039A903DA2DBEEC00@AM0PR04MB4290.eurprd04.prod.outlook.com>
Hi Leonard,
Thus wrote Leonard Crestez (leonard.crestez@nxp.com):
> On 11/10/18 7:37 PM, Martin Kaiser wrote:
> > The commit that added scu based pinctrl support introduced a regression
> > for the mmio case. In the for-loop where the maps are initialized, we
> > end up creating a partially initialized map in some cases. This causes a
> > kernel panic when such a map is used at a later stage.
> > Fixes: b96eea718bf6 ("pinctrl: fsl: add scu based pinctrl support")
> > Cc: A.s. Dong <aisheng.dong@nxp.com>
> > diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
> > @@ -108,9 +108,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
> > new_map++;
> > for (i = j = 0; i < grp->num_pins; i++) {
> > pin = &((struct imx_pin *)(grp->data))[i];
> > - new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN;
> > - new_map[j].data.configs.group_or_pin =
> > - pin_get_name(pctldev, pin->pin);
> > if (info->flags & IMX_USE_SCU) {
> > /*
> > @@ -126,7 +123,12 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
> > new_map[j].data.configs.num_configs = 1;
> > }
> > - j++;
> > + if (new_map[j].data.configs.num_configs) {
> > + new_map[j].type = PIN_MAP_TYPE_CONFIGS_PIN;
> > + new_map[j].data.configs.group_or_pin =
> > + pin_get_name(pctldev, pin->pin);
> > + j++;
> > + }
> Sorry but I don't think this is correct.
> The new_map array is allocated with kmalloc_array so we can't rely on
> new_map[j].data.configs.num_configs being initialized to zero unless
> assigned to.
you're right. There's no guarantee that the memory area is initialized
to 0.
Regards,
Martin
next prev parent reply other threads:[~2018-11-12 15:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-10 17:37 [PATCH] pinctrl: imx: make sure that maps are fully initialized Martin Kaiser
2018-11-10 17:49 ` Fabio Estevam
2018-11-11 22:37 ` Leonard Crestez
2018-11-12 15:37 ` Martin Kaiser [this message]
2018-11-12 15:04 ` A.s. Dong
2018-11-12 15:09 ` Fabio Estevam
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=20181112153721.ekgpql3pj3bbv6ee@viti.kaiser.cx \
--to=martin@kaiser.cx \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=leonard.crestez@nxp.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shawnguo@kernel.org \
--cc=stefan@agner.ch \
/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).