Message ID | 20210320232359.941-8-bvanassche@acm.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | qla2xxx patches for kernel v5.12 and v5.13 | expand |
On Sat, Mar 20, 2021 at 04:23:59PM -0700, Bart Van Assche wrote: > data = kzalloc(response_len, GFP_KERNEL); > + if (!data) { > + kfree(req_data); > + return -ENOMEM; > + } There is the host_stat_out label which could be reused for the exit path. I am not sure if this the preferred solution by the maintainers. Reviewed-by: Daniel Wagner <dwagner@suse.de>
Hi Bart, > -----Original Message----- > From: Bart Van Assche <bvanassche@acm.org> > Sent: Sunday, March 21, 2021 4:54 AM > To: Martin K . Petersen <martin.petersen@oracle.com>; James E . J . > Bottomley <jejb@linux.vnet.ibm.com> > Cc: linux-scsi@vger.kernel.org; Bart Van Assche <bvanassche@acm.org>; > Himanshu Madhani <himanshu.madhani@oracle.com>; Saurav Kashyap > <skashyap@marvell.com>; Nilesh Javali <njavali@marvell.com>; Quinn Tran > <qutran@marvell.com>; Mike Christie <michael.christie@oracle.com>; > Daniel Wagner <dwagner@suse.de>; Lee Duncan <lduncan@suse.com> > Subject: [EXT] [PATCH v3 7/7] qla2xxx: Check kzalloc() return value > > External Email > > ---------------------------------------------------------------------- > Instead of crashing if kzalloc() fails, make qla2x00_get_host_stats() > return -ENOMEM. > > Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, > target stats and initiator port") > Cc: Himanshu Madhani <himanshu.madhani@oracle.com> > Cc: Saurav Kashyap <skashyap@marvell.com> > Cc: Nilesh Javali <njavali@marvell.com> > Cc: Quinn Tran <qutran@marvell.com> > Cc: Mike Christie <michael.christie@oracle.com> > Cc: Daniel Wagner <dwagner@suse.de> > Cc: Lee Duncan <lduncan@suse.com> > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c > index bee8cf9f8123..bc84b2f389f8 100644 > --- a/drivers/scsi/qla2xxx/qla_bsg.c > +++ b/drivers/scsi/qla2xxx/qla_bsg.c > @@ -2583,6 +2583,10 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job) > } > > data = kzalloc(response_len, GFP_KERNEL); > + if (!data) { > + kfree(req_data); > + return -ENOMEM; > + } > > ret = qla2xxx_get_ini_stats(fc_bsg_to_shost(bsg_job), req_data- > >stat_type, > data, response_len); Thanks for the patch. Acked-by: Saurav Kashyap <skashyap@marvell.com>
> On Mar 20, 2021, at 6:23 PM, Bart Van Assche <bvanassche@acm.org> wrote: > > Instead of crashing if kzalloc() fails, make qla2x00_get_host_stats() > return -ENOMEM. > > Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port") > Cc: Himanshu Madhani <himanshu.madhani@oracle.com> > Cc: Saurav Kashyap <skashyap@marvell.com> > Cc: Nilesh Javali <njavali@marvell.com> > Cc: Quinn Tran <qutran@marvell.com> > Cc: Mike Christie <michael.christie@oracle.com> > Cc: Daniel Wagner <dwagner@suse.de> > Cc: Lee Duncan <lduncan@suse.com> > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c > index bee8cf9f8123..bc84b2f389f8 100644 > --- a/drivers/scsi/qla2xxx/qla_bsg.c > +++ b/drivers/scsi/qla2xxx/qla_bsg.c > @@ -2583,6 +2583,10 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job) > } > > data = kzalloc(response_len, GFP_KERNEL); > + if (!data) { > + kfree(req_data); > + return -ENOMEM; > + } > > ret = qla2xxx_get_ini_stats(fc_bsg_to_shost(bsg_job), req_data->stat_type, > data, response_len); Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> -- Himanshu Madhani Oracle Linux Engineering
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index bee8cf9f8123..bc84b2f389f8 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2583,6 +2583,10 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job) } data = kzalloc(response_len, GFP_KERNEL); + if (!data) { + kfree(req_data); + return -ENOMEM; + } ret = qla2xxx_get_ini_stats(fc_bsg_to_shost(bsg_job), req_data->stat_type, data, response_len);
Instead of crashing if kzalloc() fails, make qla2x00_get_host_stats() return -ENOMEM. Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port") Cc: Himanshu Madhani <himanshu.madhani@oracle.com> Cc: Saurav Kashyap <skashyap@marvell.com> Cc: Nilesh Javali <njavali@marvell.com> Cc: Quinn Tran <qutran@marvell.com> Cc: Mike Christie <michael.christie@oracle.com> Cc: Daniel Wagner <dwagner@suse.de> Cc: Lee Duncan <lduncan@suse.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ 1 file changed, 4 insertions(+)