lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon,  4 Jul 2022 21:35:28 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Nilesh Javali <njavali@...vell.com>,
        GR-QLogic-Storage-Upstream@...vell.com,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        linux-scsi@...r.kernel.org
Subject: [PATCH] scsi: qla2xxx: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
 drivers/scsi/qla2xxx/qla_edif.c | 12 +++++-------
 drivers/scsi/qla2xxx/qla_os.c   |  8 +++-----
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
index 400a8b6f3982..5a7b23a5479e 100644
--- a/drivers/scsi/qla2xxx/qla_edif.c
+++ b/drivers/scsi/qla2xxx/qla_edif.c
@@ -3349,8 +3349,7 @@ void qla_edif_sadb_release(struct qla_hw_data *ha)
 /* build the rx and tx sa_index free pools -- only done at fcport init */
 int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
 {
-	ha->edif_tx_sa_id_map =
-	    kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
+	ha->edif_tx_sa_id_map = bitmap_zalloc(EDIF_NUM_SA_INDEX, GFP_KERNEL);
 
 	if (!ha->edif_tx_sa_id_map) {
 		ql_log_pci(ql_log_fatal, ha->pdev, 0x0009,
@@ -3358,10 +3357,9 @@ int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
 		return -ENOMEM;
 	}
 
-	ha->edif_rx_sa_id_map =
-	    kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
+	ha->edif_rx_sa_id_map = bitmap_zalloc(EDIF_NUM_SA_INDEX, GFP_KERNEL);
 	if (!ha->edif_rx_sa_id_map) {
-		kfree(ha->edif_tx_sa_id_map);
+		bitmap_free(ha->edif_tx_sa_id_map);
 		ha->edif_tx_sa_id_map = NULL;
 		ql_log_pci(ql_log_fatal, ha->pdev, 0x0009,
 		    "Unable to allocate memory for sadb rx.\n");
@@ -3373,9 +3371,9 @@ int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
 /* release the free pool - only done during fcport teardown */
 void qla_edif_sadb_release_free_pool(struct qla_hw_data *ha)
 {
-	kfree(ha->edif_tx_sa_id_map);
+	bitmap_free(ha->edif_tx_sa_id_map);
 	ha->edif_tx_sa_id_map = NULL;
-	kfree(ha->edif_rx_sa_id_map);
+	bitmap_free(ha->edif_rx_sa_id_map);
 	ha->edif_rx_sa_id_map = NULL;
 }
 
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 1c7fb6484db2..d5f292612cda 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4356,9 +4356,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
 	INIT_LIST_HEAD(&ha->vp_list);
 
 	/* Allocate memory for our loop_id bitmap */
-	ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE),
-				  sizeof(long),
-				  GFP_KERNEL);
+	ha->loop_id_map = bitmap_zalloc(LOOPID_MAP_SIZE, GFP_KERNEL);
 	if (!ha->loop_id_map)
 		goto fail_loop_id_map;
 	else {
@@ -4418,7 +4416,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
 	dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
 	    ha->sfp_data, ha->sfp_data_dma);
 fail_sfp_data:
-	kfree(ha->loop_id_map);
+	bitmap_free(ha->loop_id_map);
 fail_loop_id_map:
 	dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
 fail_async_pd:
@@ -4948,7 +4946,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
 	ha->npiv_info = NULL;
 	kfree(ha->swl);
 	ha->swl = NULL;
-	kfree(ha->loop_id_map);
+	bitmap_free(ha->loop_id_map);
 	ha->sf_init_cb = NULL;
 	ha->sf_init_cb_dma = 0;
 	ha->loop_id_map = NULL;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ