Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1481831

[PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection
Date 2016-09-12 20:50 +0200
Message-ID <sgEsO-76N-29@gated-at.bofh.it> (permalink)
References <qEuGl-43C-5@gated-at.bofh.it> <sgEsN-76N-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 13:18:57 +0200

The functions "ceph_put_snap_context" and "kfree" were called in a few
cases by the function "rbd_header_from_disk" during error handling
even if the passed variables contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e406c27..f4212e1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1001,7 +1001,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	snap_count = le32_to_cpu(ondisk->snap_count);
 	snapc = ceph_create_snap_context(snap_count, GFP_KERNEL);
 	if (!snapc)
-		goto out_err;
+		goto free_prefix;
 	snapc->seq = le64_to_cpu(ondisk->snap_seq);
 	if (snap_count) {
 		struct rbd_image_snap_ondisk *snaps;
@@ -1013,14 +1013,14 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 			goto out_2big;
 		snap_names = kmalloc(snap_names_len, GFP_KERNEL);
 		if (!snap_names)
-			goto out_err;
+			goto put_snap_context;
 
 		/* ...as well as the array of their sizes. */
 		snap_sizes = kmalloc_array(snap_count,
 					   sizeof(*header->snap_sizes),
 					   GFP_KERNEL);
 		if (!snap_sizes)
-			goto out_err;
+			goto free_names;
 
 		/*
 		 * Copy the names, and fill in each snapshot's id
@@ -1066,10 +1066,12 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	return 0;
 out_2big:
 	ret = -EIO;
-out_err:
 	kfree(snap_sizes);
+ free_names:
 	kfree(snap_names);
+ put_snap_context:
 	ceph_put_snap_context(snapc);
+ free_prefix:
 	kfree(object_prefix);
 
 	return ret;
-- 
2.10.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 02/47] block-rbd: Less function calls in  rbd_header_from_disk() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-12 20:50 +0200
  Re: [PATCH 02/47] block-rbd: Less function calls in  rbd_header_from_disk() after error detection Ilya Dryomov <idryomov@gmail.com> - 2016-09-13 10:00 +0200

csiph-web