staging: rtl8192u: check return value of read_nic_word_E
authorSalah Triki <salah.triki@acm.org>
Wed, 4 May 2016 03:42:40 +0000 (04:42 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Jun 2016 02:49:02 +0000 (19:49 -0700)
The call of read_nic_word_E may fail, therefore its return value must be
checked and propagated in the case of error.

Signed-off-by: Salah Triki <salah.triki@acm.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/r8180_93cx6.c

index 97d9b3f49114143c74d69f63d6e427d4b8f7537f..2c53132e79cfc42fb3298b4986c21b65ed887b10 100644 (file)
 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,8 +43,11 @@ 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);
@@ -56,8 +62,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 +80,12 @@ static void eprom_w(struct net_device *dev, short bit)
 static short eprom_r(struct net_device *dev)
 {
        u8 bit;
+       int err;
+
+       err = read_nic_byte_E(dev, EPROM_CMD, &bit);
+       if (err)
+               return err;
 
-       read_nic_byte_E(dev, EPROM_CMD, &bit);
        udelay(EPROM_DELAY);
 
        if (bit & EPROM_R_BIT)