From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-gpio@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
Linus Walleij <linusw@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:KERNEL HARDENING (not covered by other
areas):Keyword:b__counted_by(_le|_be)?b"
<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH] pinctrl: intel: use FAM for communities
Date: Thu, 26 Mar 2026 12:35:51 +0200 [thread overview]
Message-ID: <acUMB5OUGCpy73eW@ashevche-desk.local> (raw)
In-Reply-To: <20260326023627.54349-1-rosenp@gmail.com>
On Wed, Mar 25, 2026 at 07:36:27PM -0700, Rosen Penev wrote:
> Use a flexible array member to combine allocations into one.
>
> Add __counted_by for extra runtime analysis. Move counting variable
> assignments to after allocation as required by __counted_by.
I don't think it improves readability of the code. Also see below.
...
> - vg = devm_kzalloc(dev, sizeof(*vg), GFP_KERNEL);
> + vg = devm_kzalloc(dev, struct_size(vg, communities, soc_data->ncommunities), GFP_KERNEL);
> if (!vg)
> return -ENOMEM;
>
> + vg->ncommunities = soc_data->ncommunities;
> + memcpy(vg->communities, soc_data->communities, soc_data->ncommunities * sizeof(*vg->communities));
This is a mess. The multiplication is used without overflow check and the parts
of it are from different data structures. If we do a such, we need to use
source data for the all of the information.
What I would like to see is rater special devm_kmalloc_and_dup()-like API
instead of doing this in every driver out of dozens of drivers.
...
> - ret = byt_set_soc_data(vg, soc_data);
> - if (ret)
> - return dev_err_probe(dev, ret, "failed to set soc data\n");
> + vg->soc = soc_data;
> +
> + for (i = 0; i < vg->soc->ncommunities; i++) {
> + struct intel_community *comm = vg->communities + i;
> +
> + comm->pad_regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(comm->pad_regs))
> + return PTR_ERR(comm->pad_regs);
> + }
Why is this can't be kept in a separate function as it was originally done?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-03-26 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 2:36 [PATCH] pinctrl: intel: use FAM for communities Rosen Penev
2026-03-26 10:35 ` Andy Shevchenko [this message]
2026-03-26 10:41 ` Andy Shevchenko
2026-03-26 19:22 ` Rosen Penev
2026-03-27 8:50 ` Andy Shevchenko
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=acUMB5OUGCpy73eW@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rosenp@gmail.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