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: <e63de5f9-97e6-6671-f2ee-f387a8e4501c@ideasonboard.com>
Date:   Sat, 6 Jan 2018 18:37:24 +0000
From:   Kieran Bingham <kieran.bingham@...asonboard.com>
To:     Guennadi Liakhovetski <g.liakhovetski@....de>
Cc:     linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        laurent.pinchart@...asonboard.com,
        Olivier BRAUN <olivier.braun@...reolabs.com>,
        kieran.bingham@...asonboard.com,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Hans Verkuil <hans.verkuil@...co.com>,
        Jaejoong Kim <climbbb.kim@...il.com>,
        Baoyou Xie <baoyou.xie@...aro.org>,
        Nicolas Dufresne <nicolas.dufresne@...labora.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jim Lin <jilin@...dia.com>,
        Daniel Patrick Johnson <teknotus@...not.us>
Subject: Re: [RFC/RFT PATCH 3/6] uvcvideo: Protect queue internals with helper

Hi Guennadi,

On 04/01/18 18:25, Guennadi Liakhovetski wrote:
> Hi Kieran,
> 
> On Wed, 3 Jan 2018, Kieran Bingham wrote:
> 
>> From: Kieran Bingham <kieran.bingham@...asonboard.com>
>>
>> The URB completion operation obtains the current buffer by reading
>> directly into the queue internal interface.
>>
>> Protect this queue abstraction by providing a helper
>> uvc_queue_get_current_buffer() which can be used by both the decode
>> task, and the uvc_queue_next_buffer() functions.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@...asonboard.com>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
>> ---
>>  drivers/media/usb/uvc/uvc_queue.c | 34 +++++++++++++++++++++++++++-----
>>  drivers/media/usb/uvc/uvc_video.c |  7 +------
>>  drivers/media/usb/uvc/uvcvideo.h  |  2 ++-
>>  3 files changed, 32 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
>> index c8d78b2f3de4..0711e3d9ff76 100644
>> --- a/drivers/media/usb/uvc/uvc_queue.c
>> +++ b/drivers/media/usb/uvc/uvc_queue.c
>> @@ -399,6 +399,34 @@ void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect)
>>  	spin_unlock_irqrestore(&queue->irqlock, flags);
>>  }
>>  
>> +/*
>> + * uvc_queue_get_current_buffer: Obtain the current working output buffer
>> + *
>> + * Buffers may span multiple packets, and even URBs, therefore the active buffer
>> + * remains on the queue until the EOF marker.
>> + */
>> +static struct uvc_buffer *
>> +__uvc_queue_get_current_buffer(struct uvc_video_queue *queue)
>> +{
>> +	if (!list_empty(&queue->irqqueue))
>> +		return list_first_entry(&queue->irqqueue, struct uvc_buffer,
>> +					queue);
>> +	else
>> +		return NULL;
> 
> I think the preferred style is not to use "else" in such cases. It might 
> even be prettier to write
> 
> 	if (list_empty(...))
> 		return NULL;
> 
> 	return list_first_entry(...);

Ah yes, I believe you are correct.
Good spot!

Fixed, and looks much neater.

--
Kieran

> 
> Thanks
> Guennadi
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ