loopback: off by one in tcm_loop_make_naa_tpg()
authorDan Carpenter <error27@gmail.com>
Sat, 2 Apr 2011 21:32:47 +0000 (14:32 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 22 Jul 2011 09:37:46 +0000 (09:37 +0000)
This is an off by one 'tgpt' check in tcm_loop_make_naa_tpg() that could result
in memory corruption.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
drivers/target/loopback/tcm_loop.c

index c2937b2..083d6c5 100644 (file)
@@ -1205,7 +1205,7 @@ struct se_portal_group *tcm_loop_make_naa_tpg(
        tpgt_str += 5; /* Skip ahead of "tpgt_" */
        tpgt = (unsigned short int) simple_strtoul(tpgt_str, &end_ptr, 0);
 
-       if (tpgt > TL_TPGS_PER_HBA) {
+       if (tpgt >= TL_TPGS_PER_HBA) {
                printk(KERN_ERR "Passed tpgt: %hu exceeds TL_TPGS_PER_HBA:"
                                " %u\n", tpgt, TL_TPGS_PER_HBA);
                return ERR_PTR(-EINVAL);