Message ID | 20230607113843.37185-4-njavali@marvell.com |
---|---|
State | New |
Headers | show |
Series | [v2,1/8] qla2xxx: klocwork - Array index may go out of bound | expand |
> On Jun 7, 2023, at 4:38 AM, Nilesh Javali <njavali@marvell.com> wrote: > > Klocwork reported warning of null pointer may be dereferenced. > The routine exits when sa_ctl is NULL and fcport is allocated after > the exit call thus causing NULL fcport pointer to dereference at the > time of exit. > > To avoid fcport pointer dereference, exit the routine when > sa_ctl is NULL. > > Cc: stable@vger.kernel.org > Signed-off-by: Nilesh Javali <njavali@marvell.com> > --- > v2: > - Exit the routine if sa_ctl is NULL. > > drivers/scsi/qla2xxx/qla_edif.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c > index ec0e20255bd3..26e6b3e3af43 100644 > --- a/drivers/scsi/qla2xxx/qla_edif.c > +++ b/drivers/scsi/qla2xxx/qla_edif.c > @@ -2361,8 +2361,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e) > if (!sa_ctl) { > ql_dbg(ql_dbg_edif, vha, 0x70e6, > "sa_ctl allocation failed\n"); > - rval = -ENOMEM; > - goto done; > + rval = -ENOMEM; > + return rval; > } > > fcport = sa_ctl->fcport; > -- > 2.23.1 > Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c index ec0e20255bd3..26e6b3e3af43 100644 --- a/drivers/scsi/qla2xxx/qla_edif.c +++ b/drivers/scsi/qla2xxx/qla_edif.c @@ -2361,8 +2361,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e) if (!sa_ctl) { ql_dbg(ql_dbg_edif, vha, 0x70e6, "sa_ctl allocation failed\n"); - rval = -ENOMEM; - goto done; + rval = -ENOMEM; + return rval; } fcport = sa_ctl->fcport;
Klocwork reported warning of null pointer may be dereferenced. The routine exits when sa_ctl is NULL and fcport is allocated after the exit call thus causing NULL fcport pointer to dereference at the time of exit. To avoid fcport pointer dereference, exit the routine when sa_ctl is NULL. Cc: stable@vger.kernel.org Signed-off-by: Nilesh Javali <njavali@marvell.com> --- v2: - Exit the routine if sa_ctl is NULL. drivers/scsi/qla2xxx/qla_edif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)