From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hongren Zheng <i@zenithal.me>
Cc: Shuah Khan <shuah@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Valentina Manea <valentina.manea.m@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
sfr@canb.auug.org.au
Subject: Re: [PATCH -next] usb/usbip: fix wrong data added to platform device
Date: Fri, 13 Oct 2023 22:58:02 +0300 [thread overview]
Message-ID: <ZSmhSozvQfggY8Cg@smile.fi.intel.com> (raw)
In-Reply-To: <ZSkhWa5wmAGsAdCK@Sun>
On Fri, Oct 13, 2023 at 06:52:09PM +0800, Hongren Zheng wrote:
> .data of platform_device_info will be copied into .platform_data of
> struct device via platform_device_add_data.
>
> However, vhcis[i] contains a spinlock, is dynamically allocated and
> used by other code, so it is not meant to be copied. The workaround
> was to use void *vhci as an agent, but it was removed in the commit
> suggested below.
>
> This patch adds back the workaround and changes the way of using
> platform_data accordingly.
...
One more thing...
> static int __init vhci_hcd_init(void)
> {
> int i, ret;
> + void *vhci;
>
> if (usb_disabled())
> return -ENODEV;
> @@ -1522,10 +1522,11 @@ static int __init vhci_hcd_init(void)
> goto err_driver_register;
>
> for (i = 0; i < vhci_num_controllers; i++) {
> + vhci = &vhcis[i];
This should be
void *vhci = &vhcis[i];
because otherwise we mix code and definitions which is not so good style. (Yet
we allow to do that in exceptional cases: 1) iterators in for-loops, and 2)
RAII allocations with __free() in use.)
> struct platform_device_info pdevinfo = {
> .name = driver_name,
> .id = i,
> - .data = &vhcis[i],
> + .data = &vhci,
> .size_data = sizeof(void *),
> };
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2023-10-13 19:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 10:52 Hongren Zheng
2023-10-13 12:05 ` Hongren Zheng
2023-10-13 19:55 ` Andy Shevchenko
2023-10-13 19:58 ` Andy Shevchenko [this message]
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=ZSmhSozvQfggY8Cg@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@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
all inboxes | Powered by JetHome®