Message ID | 20230518075841.40363-4-njavali@marvell.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | qla2xxx klocwork fixes | expand |
On 5/18/23 00:58, Nilesh Javali 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. > > Add a check for a valid fcport pointer at the time of exit. > > Cc: stable@vger.kernel.org > Signed-off-by: Nilesh Javali <njavali@marvell.com> > --- > drivers/scsi/qla2xxx/qla_edif.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c > index ec0e20255bd3..14e314c12dd6 100644 > --- a/drivers/scsi/qla2xxx/qla_edif.c > +++ b/drivers/scsi/qla2xxx/qla_edif.c > @@ -2411,7 +2411,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e) > kref_put(&sp->cmd_kref, qla2x00_sp_release); > fcport->flags &= ~FCF_ASYNC_SENT; > done: > - fcport->flags &= ~FCF_ASYNC_ACTIVE; > + if (fcport) > + fcport->flags &= ~FCF_ASYNC_ACTIVE; > return rval; > } Please change the "goto done" statements that occur before fcport is set into "return rval" instead of making the above change. Bart.
diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c index ec0e20255bd3..14e314c12dd6 100644 --- a/drivers/scsi/qla2xxx/qla_edif.c +++ b/drivers/scsi/qla2xxx/qla_edif.c @@ -2411,7 +2411,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e) kref_put(&sp->cmd_kref, qla2x00_sp_release); fcport->flags &= ~FCF_ASYNC_SENT; done: - fcport->flags &= ~FCF_ASYNC_ACTIVE; + if (fcport) + fcport->flags &= ~FCF_ASYNC_ACTIVE; return rval; }
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. Add a check for a valid fcport pointer at the time of exit. Cc: stable@vger.kernel.org Signed-off-by: Nilesh Javali <njavali@marvell.com> --- drivers/scsi/qla2xxx/qla_edif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)