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] [day] [month] [year] [list]
Message-ID: <CAMuHMdXA3FV+NstypjCLVg78THQawt-s=xWHRJK+reNYa9Oqnw@mail.gmail.com>
Date:   Fri, 12 May 2017 09:07:18 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Cc:     SF Markus Elfring <elfring@...rs.sourceforge.net>,
        Linux Fbdev development list <linux-fbdev@...r.kernel.org>,
        "linux-omap@...r.kernel.org" <linux-omap@...r.kernel.org>,
        Tomi Valkeinen <tomi.valkeinen@...com>,
        LKML <linux-kernel@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe()

On Thu, May 11, 2017 at 5:22 PM, Bartlomiej Zolnierkiewicz
<b.zolnierkie@...sung.com> wrote:
> On Thursday, May 11, 2017 04:27:19 PM Bartlomiej Zolnierkiewicz wrote:
>
>> > @@ -358,11 +358,7 @@ static int __init vrfb_probe(struct platform_device *pdev)
>> >             return PTR_ERR(vrfb_base);
>> >
>> >     num_ctxs = pdev->num_resources - 1;
>> > -
>> > -   ctxs = devm_kzalloc(&pdev->dev,
>> > -                   sizeof(struct vrfb_ctx) * num_ctxs,
>> > -                   GFP_KERNEL);
>> > -
>> > +   ctxs = devm_kcalloc(&pdev->dev, num_ctxs, sizeof(*ctxs), GFP_KERNEL);
>>
>> This change makes the resulting binary larger by 24 bytes (probably
>> because of the need to have an additional function argument) and
>
> 24 bytes seemed too much for just an additional function argument
> so I've checked the source:
>
> static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
> {
>         return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
> }
> static inline void *devm_kmalloc_array(struct device *dev,
>                                        size_t n, size_t size, gfp_t flags)
> {
>         if (size != 0 && n > SIZE_MAX / size)
>                 return NULL;
>         return devm_kmalloc(dev, n * size, flags);
> }
> static inline void *devm_kcalloc(struct device *dev,
>                                  size_t n, size_t size, gfp_t flags)
> {
>         return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
> }
>
> The extra kcalloc() checks are inlined currently into each instance.

And in this case the compiler cannot optimize them away as n is not
known at compile time.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ