From: Bart Van Assche <bvanassche@xxxxxxx> [ Upstream commit e5406d8ad4a1659f4d4d1b39fe203855c4eaef2d ] Instead of crashing if kzalloc() fails, make qla2x00_get_host_stats() return -ENOMEM. Link: https://lore.kernel.org/r/20210320232359.941-8-bvanassche@xxxxxxx Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port") Cc: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx> Cc: Saurav Kashyap <skashyap@xxxxxxxxxxx> Cc: Nilesh Javali <njavali@xxxxxxxxxxx> Cc: Quinn Tran <qutran@xxxxxxxxxxx> Cc: Mike Christie <michael.christie@xxxxxxxxxx> Cc: Daniel Wagner <dwagner@xxxxxxx> Cc: Lee Duncan <lduncan@xxxxxxxx> Reviewed-by: Daniel Wagner <dwagner@xxxxxxx> Reviewed-by: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx> Acked-by: Saurav Kashyap <skashyap@xxxxxxxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> --- 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 d021e51344f5..aef2f7cc89d3 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2584,6 +2584,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); -- 2.30.2