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>] [day] [month] [year] [list]
Message-ID: <CAK8P3a3M5ppNKwthz5NcCrXc74r1aG9aJhQXzaP-Fa5a81U8yw@mail.gmail.com>
Date:   Tue, 30 Oct 2018 21:08:54 +0100
From:   Arnd Bergmann <arnd@...db.de>
To:     Alan Cooper <alcooperx@...il.com>
Cc:     ": Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
        Alan Stern <stern@...land.harvard.edu>,
        Alban Bedel <albeu@...e.fr>, Alex Elder <elder@...aro.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Avi Fishman <avifishman70@...il.com>,
        bcm-kernel-feedback-list@...adcom.com,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Chunfeng Yun <chunfeng.yun@...iatek.com>,
        David Miller <davem@...emloft.net>,
        DTML <devicetree@...r.kernel.org>,
        Dmitry Osipenko <digetx@...il.com>,
        gregkh <gregkh@...uxfoundation.org>,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        Hans de Goede <hdegoede@...hat.com>,
        James Hogan <jhogan@...nel.org>,
        Jianguo Sun <sunjianguo1@...wei.com>,
        Johan Hovold <johan@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        USB list <linux-usb@...r.kernel.org>,
        Lu Baolu <baolu.lu@...ux.intel.com>,
        Mark Rutland <mark.rutland@....com>,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        Mathias Nyman <mathias.nyman@...el.com>,
        Mathias Nyman <mathias.nyman@...ux.intel.com>,
        Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
        Rishabh Bhatnagar <rishabhb@...eaurora.org>,
        Rob Herring <robh+dt@...nel.org>, Roger Quadros <rogerq@...com>
Subject: Re: [PATCH V2 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's

On 10/30/18, Alan Cooper <alcooperx@...il.com> wrote:
>> On 10/24/18 3:11 AM, Arnd Bergmann wrote:
>>
>> On Wed, Oct 17, 2018 at 11:30 PM Al Cooper <alcooperx@...il.com> wrote:
>>
>> Add support for Broadcom STB SoC's to the ohci platform driver.
>>
>> Signed-off-by: Al Cooper <alcooperx@...il.com>
>> ---
>>  drivers/usb/host/ohci-platform.c | 35
>> +++++++++++++++++++++++++++++------
>>  include/linux/usb/ohci_pdriver.h |  1 +
>>  2 files changed, 30 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-platform.c
> b/drivers/usb/host/ohci-platform.c
>> index 65a1c3fdc88c..363d6fa676a5 100644
>> --- a/drivers/usb/host/ohci-platform.c
>> +++ b/drivers/usb/host/ohci-platform.c
>> @@ -22,6 +22,7 @@
>>  #include <linux/module.h>
>>  #include <linux/err.h>
>>  #include <linux/of.h>
>> +#include <linux/of_device.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/pm_runtime.h>
>>  #include <linux/reset.h>
>> @@ -99,12 +100,24 @@ static int ohci_platform_probe(struct
> platform_device *dev)
>>         if (usb_disabled())
>>                 return -ENODEV;
>>
>> -       /*
>> -        * Use reasonable defaults so platforms don't have to provide
> these
>> -        * with DT probing on ARM.
>> -        */
>> -       if (!pdata)
>> -               pdata = &ohci_platform_defaults;
>> +       if (!pdata) {
>> +               const struct usb_ohci_pdata *match_pdata;
>> +
>> +               match_pdata = of_device_get_match_data(&dev->dev);
>> +               if (match_pdata) {
>> +                       pdata = devm_kzalloc(&dev->dev, sizeof(*pdata),
>> +                                            GFP_KERNEL);
>> +                       if (!pdata)
>> +                               return -ENOMEM;
>> +                       *pdata = *match_pdata;
>>
>> It looks like you copy the const pdata to get a non-const version.
>> Have you tried
>> propagating the 'const' modifier so that users can rely on that here?
>
> The problem is that the const pdata from of_device_get_match() needs to be
> saved in device->platform_data which is not a const pointer (and can't be
> changed). How can I propagate the "const" to solve the problem?

Ah, I see your problem, and unfortunately don't have an easy answer.

You could split up the structure between a constant part and a non-constant
part, and have the latter be what gets put into the platform_data, but that
wouldn't really be much nicer than what you have here.

You could use devm_kmemdup() to save a few lines to simplify your
code without any other changes maybe, but it doesn't solve the
fact that the mismatch between platform_data being non-const and
of_match_data being const is a bit ugly.

        Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ