From 20e0fe94f593b4e62e6a31a050d918b6a2c03a5a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 29 Oct 2020 03:23:04 +0000 Subject: [PATCH] scst: Fix allocation of memory for latency statistics for the GFP_ATOMIC case See also https://sourceforge.net/p/scst/tickets/43/. Reported-by: Steven Siwinski git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9174 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 10 ++++++++-- scst/src/scst_sysfs.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 1a9391c75..29f75016b 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7173,7 +7173,13 @@ struct scst_session *scst_alloc_session(struct scst_tgt *tgt, gfp_t gfp_mask, } if (atomic_read(&scst_measure_latency)) { - sess->lat_stats = vzalloc(sizeof(*sess->lat_stats)); + /* + * To do: remove higher order allocation from the code below + * for the GFP_ATOMIC case. + */ + sess->lat_stats = gfp_mask & GFP_ATOMIC ? + kzalloc(sizeof(*sess->lat_stats), gfp_mask) : + vzalloc(sizeof(*sess->lat_stats)); if (!sess->lat_stats) goto out_free_name; } @@ -7232,7 +7238,7 @@ void scst_free_session(struct scst_session *sess) mutex_unlock(&scst_mutex); kfree(sess->transport_id); - vfree(sess->lat_stats); + kvfree(sess->lat_stats); kfree(sess->initiator_name); if (sess->sess_name != sess->initiator_name) kfree(sess->sess_name); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index c0f931374..24a596aca 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -6986,7 +6986,7 @@ static void scst_free_lat_stats_mem(void) list_for_each_entry(tgt, &tt->tgt_list, tgt_list_entry) { list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) { - vfree(sess->lat_stats); + kvfree(sess->lat_stats); sess->lat_stats = NULL; } }