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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1380547556-17719-5-git-send-email-b.zolnierkie@samsung.com>
Date:	Mon, 30 Sep 2013 15:25:45 +0200
From:	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
To:	axboe@...nel.dk
Cc:	abhansali@...c-inc.com, jmoyer@...hat.com,
	kyungmin.park@...sung.com, linux-kernel@...r.kernel.org,
	b.zolnierkie@...sung.com
Subject: [PATCH 04/14] skd: alloc flush slab only if some devices are present

Allocate flush slab in skd_pci_probe() instead of in skd_init() so it
is allocated only if some devices are present (currently it is always
allocated when the driver is loaded).

Cc: Akhil Bhansali <abhansali@...c-inc.com>
Cc: Jeff Moyer <jmoyer@...hat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
 drivers/block/skd_main.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 04eb9bd..e63a63c 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -5203,6 +5203,18 @@ static int skd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		}
 	}
 
+	if (!skd_flush_slab) {
+		skd_flush_slab = kmem_cache_create(SKD_FLUSH_JOB,
+						  sizeof(struct skd_flush_cmd),
+						  0, 0, NULL);
+		if (!skd_flush_slab) {
+			pr_err("(%s): failed to allocate flush slab\n",
+			       pci_name(pdev));
+			rc = -ENOMEM;
+			goto err_out_regions;
+		}
+	}
+
 	skdev = skd_construct(pdev);
 	if (skdev == NULL)
 		goto err_out_regions;
@@ -5714,14 +5726,6 @@ static int __init skd_init(void)
 		skd_isr_type = SKD_IRQ_DEFAULT;
 	}
 
-	skd_flush_slab = kmem_cache_create(SKD_FLUSH_JOB,
-					  sizeof(struct skd_flush_cmd),
-					  0, 0, NULL);
-	if (!skd_flush_slab) {
-		pr_err(PFX "failed to allocate flush slab\n");
-		goto err_kmem_cache_create;
-	}
-
 	if (skd_max_queue_depth < 1 ||
 	    skd_max_queue_depth > SKD_MAX_QUEUE_DEPTH) {
 		pr_err(PFX "skd_max_queue_depth %d invalid, re-set to %d\n",
@@ -5776,9 +5780,6 @@ err_pci_register_driver:
 	unregister_blkdev(skd_major, DRV_NAME);
 
 err_register_blkdev:
-	kmem_cache_destroy(skd_flush_slab);
-
-err_kmem_cache_create:
 	return rc;
 }
 
@@ -5790,7 +5791,8 @@ static void __exit skd_exit(void)
 
 	unregister_blkdev(skd_major, DRV_NAME);
 
-	kmem_cache_destroy(skd_flush_slab);
+	if (skd_flush_slab)
+		kmem_cache_destroy(skd_flush_slab);
 }
 
 static int
-- 
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ