cxgb4: Fix t4_flash_erase_sectors() to throw an error when requested to erase sectors...
authorHariprasad Shenai <hariprasad@chelsio.com>
Wed, 10 Sep 2014 12:14:29 +0000 (17:44 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Sep 2014 21:01:54 +0000 (14:01 -0700)
Based on original work by Casey Leedom <leedom@chelsio.com>

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

index 7d4cc28ca36525dc2a1006614a9239e9c4a7fb00..586a5f1fba0f73bee7e6a1457631df361ca5cf95 100644 (file)
@@ -1099,6 +1099,9 @@ static int t4_flash_erase_sectors(struct adapter *adapter, int start, int end)
 {
        int ret = 0;
 
+       if (end >= adapter->params.sf_nsec)
+               return -EINVAL;
+
        while (start <= end) {
                if ((ret = sf1_write(adapter, 1, 0, 1, SF_WR_ENABLE)) != 0 ||
                    (ret = sf1_write(adapter, 4, 0, 1,