[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZSmhSozvQfggY8Cg@smile.fi.intel.com>
Date: Fri, 13 Oct 2023 22:58:02 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Hongren Zheng <i@...ithal.me>
Cc: Shuah Khan <shuah@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Valentina Manea <valentina.manea.m@...il.com>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
sfr@...b.auug.org.au
Subject: Re: [PATCH -next] usb/usbip: fix wrong data added to platform device
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
Powered by blists - more mailing lists