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: <e8dd9233-589d-4e57-8a58-593789c8eae1@email.android.com>
Date:	Wed, 24 Oct 2012 19:10:45 -0400
From:	Andy Walls <awalls@...metrocast.net>
To:	Laurent Pinchart <laurent.pinchart@...asonboard.com>,
	Ezequiel Garcia <elezegarcia@...il.com>
CC:	linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
	Julia.Lawall@...6.fr, kernel-janitors@...r.kernel.org,
	Peter Senna Tschudin <peter.senna@...il.com>
Subject: Re: [PATCH 01/23] uvc: Replace memcpy with struct assignment

Laurent Pinchart <laurent.pinchart@...asonboard.com> wrote:

>Hi Ezequiel,
>
>Thanks for the patch.
>
>On Tuesday 23 October 2012 16:57:04 Ezequiel Garcia wrote:
>> This kind of memcpy() is error-prone. Its replacement with a struct
>> assignment is prefered because it's type-safe and much easier to
>read.
>> 
>> Found by coccinelle. Hand patched and reviewed.
>> Tested by compilation only.
>
>This looks good, but there's one more memcpy that can be replaced by a
>direct 
>structure assignment in uvc_ctrl_add_info() 
>(drivers/media/usb/uvc/uvc_ctrl.c). You might want to check why it
>hasn't been 
>caught by the semantic patch.
>
>> A simplified version of the semantic match that finds this problem is
>as
>> follows: (http://coccinelle.lip6.fr/)
>> 
>> // <smpl>
>> @@
>> identifier struct_name;
>> struct struct_name to;
>> struct struct_name from;
>> expression E;
>> @@
>> -memcpy(&(to), &(from), E);
>> +to = from;
>> // </smpl>
>> 
>> Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>
>> Signed-off-by: Peter Senna Tschudin <peter.senna@...il.com>
>> Signed-off-by: Ezequiel Garcia <elezegarcia@...il.com>
>> ---
>>  drivers/media/usb/uvc/uvc_v4l2.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
>> b/drivers/media/usb/uvc/uvc_v4l2.c index f00db30..4fc8737 100644
>> --- a/drivers/media/usb/uvc/uvc_v4l2.c
>> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
>> @@ -314,7 +314,7 @@ static int uvc_v4l2_set_format(struct
>uvc_streaming
>> *stream, goto done;
>>  	}
>> 
>> -	memcpy(&stream->ctrl, &probe, sizeof probe);
>> +	stream->ctrl = probe;
>>  	stream->cur_format = format;
>>  	stream->cur_frame = frame;
>> 
>> @@ -386,7 +386,7 @@ static int uvc_v4l2_set_streamparm(struct
>uvc_streaming
>> *stream, return -EBUSY;
>>  	}
>> 
>> -	memcpy(&probe, &stream->ctrl, sizeof probe);
>> +	probe = stream->ctrl;
>>  	probe.dwFrameInterval =
>>  		uvc_try_frame_interval(stream->cur_frame, interval);
>> 
>> @@ -397,7 +397,7 @@ static int uvc_v4l2_set_streamparm(struct
>uvc_streaming
>> *stream, return ret;
>>  	}
>> 
>> -	memcpy(&stream->ctrl, &probe, sizeof probe);
>> +	stream->ctrl = probe;
>>  	mutex_unlock(&stream->mutex);
>> 
>>  	/* Return the actual frame period. */
>
>-- 
>Regards,
>
>Laurent Pinchart
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-media"
>in
>the body of a message to majordomo@...r.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

Maybe because there is no '&' operator on the second argument. 

Regards,
Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ