Skip to contentSkip to conversation

target/core: Use kvcalloc() instead of open-coding it

PATCH Applied Bart Van Assche 1 participant 1 message Nov 27, 2018 SCSI target

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/10 target/core: Use kvcalloc() instead of open-coding it

This patch does not change any functionality. Note: the code that frees sess_cmd_map already uses kvfree() so that code does not need to be modified.

Cc Nicholas Bellinger <[email protected]>
Cc Mike Christie <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
---
 drivers/target/target_core_transport.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/target/target_core_transport.c +4 -7
index 2cfd61d62e97..d9e4b736312e 100644
@@ -273,14 +273,11 @@ int transport_alloc_session_tags(struct se_session *se_sess,
 {
 	int rc;
 
-	se_sess->sess_cmd_map = kcalloc(tag_size, tag_num,
-					GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL);
+	se_sess->sess_cmd_map = kvcalloc(tag_size, tag_num,
+					 GFP_KERNEL | __GFP_RETRY_MAYFAIL);
 	if (!se_sess->sess_cmd_map) {
-		se_sess->sess_cmd_map = vzalloc(array_size(tag_size, tag_num));
-		if (!se_sess->sess_cmd_map) {
-			pr_err("Unable to allocate se_sess->sess_cmd_map\n");
-			return -ENOMEM;
-		}
+		pr_err("Unable to allocate se_sess->sess_cmd_map\n");
+		return -ENOMEM;
 	}
 
 	rc = sbitmap_queue_init_node(&se_sess->sess_tag_pool, tag_num, -1,
Signature · 1 line
2.20.0.rc0.387.gc7a69e6b6c-goog