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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MenAwfAwf-YsoJeBEdDQat6K+snzP5FHqQ+OZ7DFyjEEw@mail.gmail.com>
Date:   Thu, 14 Dec 2017 15:30:33 +0100
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Joe Perches <joe@...ches.com>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        linux-gpio@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] gpiolib: use kstrdup_const() for gpio_device label

2017-12-13 20:44 GMT+01:00 Joe Perches <joe@...ches.com>:
> On Wed, 2017-12-13 at 12:25 +0100, Bartosz Golaszewski wrote:
>> Users often pass a pointer to a static string to gpiochip_add_data()
>> family of functions. Avoid unnecessary memory allocations with the
>> provided helper routine.
> []
>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> []
>> @@ -1171,9 +1171,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
>>       }
>>
>>       if (chip->label)
>> -             gdev->label = kstrdup(chip->label, GFP_KERNEL);
>> +             gdev->label = kstrdup_const(chip->label, GFP_KERNEL);
>>       else
>> -             gdev->label = kstrdup("unknown", GFP_KERNEL);
>> +             gdev->label = kstrdup_const("unknown", GFP_KERNEL);
>
> A plain ?: would be more intelligible
> and a bit smaller object code too.
>
> ie:
>         gdev->label = kstrdup_const(chip->label ?: "unknown", GFP_KERNEL);
>
>>       if (!gdev->label) {
>>               status = -ENOMEM;
>>               goto err_free_descs;
>

Good point. Sent v2.

Thanks,
Bartosz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ