mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
cxlflash: a couple off by one bugs
[ Upstream commit e37390bee6 ]
The "> MAX_CONTEXT" should be ">= MAX_CONTEXT". Otherwise we go one
step beyond the end of the cfg->ctx_tbl[] array.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
acafdb31f5
commit
edf9459008
@@ -1380,7 +1380,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxid = cxl_process_element(ctx);
|
ctxid = cxl_process_element(ctx);
|
||||||
if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
|
if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
|
||||||
dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
|
dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
|
||||||
rc = -EPERM;
|
rc = -EPERM;
|
||||||
goto err2;
|
goto err2;
|
||||||
@@ -1508,7 +1508,7 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxid = cxl_process_element(ctx);
|
ctxid = cxl_process_element(ctx);
|
||||||
if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
|
if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
|
||||||
dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
|
dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
|
||||||
rc = -EPERM;
|
rc = -EPERM;
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|||||||
Reference in New Issue
Block a user