Re: [PATCH 03/46] [media] soc_camera: use kmemdup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mauro,

On Wed, 3 Sep 2014, Mauro Carvalho Chehab wrote:

> Instead of calling kzalloc and then copying, use kmemdup(). That
> avoids zeroing the data structure before copying.
> 
> Found by coccinelle.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@xxxxxxxxxxx>
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index f4308fed5431..ee8cdc95a9f9 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
>  		return -ENODEV;
>  	}
>  
> -	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
> +	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
>  	if (!ssdd) {
>  		ret = -ENOMEM;
>  		goto ealloc;
>  	}
> -
> -	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));

Hm, wow... that seems  to be a particularly silly one... Even if not 
memdup, why did I use kZalloc() to immediately overwrite it completely?.. 
Thanks for catching! This and the other two (so far) patches - would you 
like me to pull-push them or just use my

Acked-by: Guennadi Liakhovetski <g.liakhovetski@xxxxxx>

for all 3 of them?

Thanks
Guennadi

>  	/*
>  	 * In synchronous case we request regulators ourselves in
>  	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
> -- 
> 1.9.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux