mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
cxlflash: a couple off by one bugs
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>
This commit is contained in:
parent
23211c1e7a
commit
e37390bee6
1 changed files with 2 additions and 2 deletions
|
@ -1380,7 +1380,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
|
|||
}
|
||||
|
||||
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);
|
||||
rc = -EPERM;
|
||||
goto err2;
|
||||
|
@ -1508,7 +1508,7 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
|
|||
}
|
||||
|
||||
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);
|
||||
rc = -EPERM;
|
||||
goto err1;
|
||||
|
|
Loading…
Reference in a new issue