Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639546

Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe()

From Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Newsgroups linux.kernel
Subject Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe()
Date 2017-05-11 16:30 +0200
Message-ID <tFXgn-7ta-53@gated-at.bofh.it> (permalink)
References <tFXgn-7ta-55@gated-at.bofh.it> <tArAu-oA-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

On Wednesday, April 26, 2017 11:20:07 AM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 26 Apr 2017 11:08:30 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "devm_kcalloc".
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/video/fbdev/omap2/omapfb/vrfb.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/video/fbdev/omap2/omapfb/vrfb.c b/drivers/video/fbdev/omap2/omapfb/vrfb.c
> index f346b02eee1d..54b51a7a290a 100644
> --- a/drivers/video/fbdev/omap2/omapfb/vrfb.c
> +++ b/drivers/video/fbdev/omap2/omapfb/vrfb.c
> @@ -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
I don't see an improvement from a security POV (pdev->num_resources
is based on the size of static tables from arch/arm/mach-omap2/fb.c).

I'm sorry but I'm not applying this patch.

>  	if (!ctxs)
>  		return -ENOMEM;

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 11:40 +0200
  Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-05-11 16:30 +0200
    Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-05-11 17:30 +0200
      Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-05-12 09:10 +0200

csiph-web