s390/dasd: fix possible buffer overflow in copy_pair_show

dasd_copy_relation->entry[] array might be accessed out of bounds if the
loop does not break.

Fixes: a91ff09d39 ("s390/dasd: add copy pair setup")
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Link: https://lore.kernel.org/r/20221123160719.3002694-5-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Stefan Haberland
2022-11-23 17:07:19 +01:00
committed by Jens Axboe
parent 590ce6d96d
commit 7e8a05b47b

View File

@@ -1954,7 +1954,7 @@ dasd_copy_pair_show(struct device *dev,
break;
}
}
if (!copy->entry[i].primary)
if (i == DASD_CP_ENTRIES)
goto out;
/* print all secondary */