Re: [PATCH] staging: rtl8192u: check return value of read_nic_word_E

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

 



On Fri, Feb 19, 2016 at 01:57:43AM +0100, Salah Triki wrote:
> The call of read_nic_word_E may fail, therefore its return value
> must be checked.
> 
> Signed-off-by: Salah Triki <salah.triki@xxxxxxx>
> ---
>  drivers/staging/rtl8192u/r8180_93cx6.c | 24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c
> index 97d9b3f..7491b21 100644
> --- a/drivers/staging/rtl8192u/r8180_93cx6.c
> +++ b/drivers/staging/rtl8192u/r8180_93cx6.c
> @@ -23,8 +23,11 @@
>  static void eprom_cs(struct net_device *dev, short bit)
>  {
>  	u8 cmdreg;
> +	int err;
>  
> -	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	if (err)
> +		return;
>  	if (bit)
>  		/* enable EPROM */
>  		write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CS_BIT);
> @@ -40,13 +43,18 @@ static void eprom_cs(struct net_device *dev, short bit)
>  static void eprom_ck_cycle(struct net_device *dev)
>  {
>  	u8 cmdreg;
> +	int err;
>  
> -	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	if (err)
> +		return;
>  	write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CK_BIT);
>  	force_pci_posting(dev);
>  	udelay(EPROM_DELAY);
>  
> -	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	if (err)
> +		return;
>  	write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CK_BIT);
>  	force_pci_posting(dev);
>  	udelay(EPROM_DELAY);
> @@ -56,8 +64,11 @@ static void eprom_ck_cycle(struct net_device *dev)
>  static void eprom_w(struct net_device *dev, short bit)
>  {
>  	u8 cmdreg;
> +	int err;
>  
> -	read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
> +	if (err)
> +		return;
>  	if (bit)
>  		write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_W_BIT);
>  	else
> @@ -71,8 +82,11 @@ static void eprom_w(struct net_device *dev, short bit)
>  static short eprom_r(struct net_device *dev)
>  {
>  	u8 bit;
> +	int err;
>  
> -	read_nic_byte_E(dev, EPROM_CMD, &bit);
> +	err = read_nic_byte_E(dev, EPROM_CMD, &bit);
> +	if (err)
> +		return 1;

Why did you return "success" for this error?

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux