Thread (20 messages) 20 messages, 6 authors, 2023-07-31

Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions

From: Jan Kara <jack@suse.cz>
Date: 2023-07-05 10:21:35
Also in: dm-devel, linux-bcache, linux-block, linux-btrfs, linux-ext4, linux-f2fs-devel, linux-fsdevel, linux-mm, linux-nfs, linux-nvme, linux-pm, linux-s390, linux-scsi, linux-xfs, target-devel, xen-devel

On Tue 04-07-23 10:28:36, Keith Busch wrote:
On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
quoted
+struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
+		void *holder, const struct blk_holder_ops *hops)
+{
+	struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
+					     GFP_KERNEL);
I believe 'sizeof(*handle)' is the preferred style.
OK.
quoted
+	struct block_device *bdev;
+
+	if (!handle)
+		return ERR_PTR(-ENOMEM);
+	bdev = blkdev_get_by_dev(dev, mode, holder, hops);
+	if (IS_ERR(bdev))
+		return ERR_CAST(bdev);
Need a 'kfree(handle)' before the error return. Or would it be simpler
to get the bdev first so you can check the mode settings against a
read-only bdev prior to the kmalloc?
Yeah. Good point with kfree(). I'm not sure calling blkdev_get_by_dev()
first will be "simpler" - then we need blkdev_put() in case of kmalloc()
failure. Thanks for review!
 
								Honza
-- 
Jan Kara [off-list ref]
SUSE Labs, CR
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help