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]
Date:	Sun, 25 May 2008 10:37:51 -0500 (CDT)
From:	Mike Isely <isely@...ly.net>
To:	David Woodhouse <dwmw2@...radead.org>
cc:	Hans Verkuil <hverkuil@...all.nl>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	sam@...nborg.org, Alan Cox <alan@...rguk.ukuu.org.uk>,
	akpm@...ux-foundation.org, Tyler Trafford <ttrafford@...il.com>,
	Mike Isely at pobox <isely@...ox.com>
Subject: Re: [PATCHv2 04/28] cx25840: treat firmware data as const

On Sun, 25 May 2008, David Woodhouse wrote:

> Hm, looks like I was also passing the wrong pointer to fw_write().
> Here's the new version...
> 
> commit 57dc4762554119ffb5c711b2716f47997bc5c181
> Author: David Woodhouse <dwmw2@...radead.org>
> Date:   Fri May 23 23:58:24 2008 +0100
> 
>     cx25840: treat firmware data as const
>     
>     Signed-off-by: David Woodhouse <dwmw2@...radead.org>

Just to be technically correct, this is what I tested successfully with 
the pvrusb2 driver.

Acked-By: Mike Isely <isely@...ox.com>

  -Mike


> 
> diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
> index 620d295..8d489a4 100644
> --- a/drivers/media/video/cx25840/cx25840-firmware.c
> +++ b/drivers/media/video/cx25840/cx25840-firmware.c
> @@ -79,7 +79,7 @@ static int check_fw_load(struct i2c_client *client, int size)
>  	return 0;
>  }
>  
> -static int fw_write(struct i2c_client *client, u8 *data, int size)
> +static int fw_write(struct i2c_client *client, const u8 *data, int size)
>  {
>  	if (i2c_master_send(client, data, size) < size) {
>  		v4l_err(client, "firmware load i2c failure\n");
> @@ -93,7 +93,8 @@ int cx25840_loadfw(struct i2c_client *client)
>  {
>  	struct cx25840_state *state = i2c_get_clientdata(client);
>  	const struct firmware *fw = NULL;
> -	u8 buffer[4], *ptr;
> +	u8 buffer[FWSEND];
> +	const u8 *ptr;
>  	int size, retval;
>  
>  	if (state->is_cx23885)
> @@ -108,29 +109,23 @@ int cx25840_loadfw(struct i2c_client *client)
>  
>  	buffer[0] = 0x08;
>  	buffer[1] = 0x02;
> -	buffer[2] = fw->data[0];
> -	buffer[3] = fw->data[1];
> -	retval = fw_write(client, buffer, 4);
>  
> -	if (retval < 0) {
> -		release_firmware(fw);
> -		return retval;
> -	}
> -
> -	size = fw->size - 2;
> +	size = fw->size;
>  	ptr = fw->data;
>  	while (size > 0) {
> -		ptr[0] = 0x08;
> -		ptr[1] = 0x02;
> -		retval = fw_write(client, ptr, min(FWSEND, size + 2));
> +		int len = min(FWSEND - 2, size);
> +
> +		memcpy(buffer + 2, ptr, len);
> +
> +		retval = fw_write(client, buffer, len + 2);
>  
>  		if (retval < 0) {
>  			release_firmware(fw);
>  			return retval;
>  		}
>  
> -		size -= FWSEND - 2;
> -		ptr += FWSEND - 2;
> +		size -= len;
> +		ptr += len;
>  	}
>  
>  	end_fw_load(client);
> 
> 

-- 

Mike Isely
isely @ pobox (dot) com
PGP: 03 54 43 4D 75 E5 CC 92 71 16 01 E2 B5 F5 C1 E8
--
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