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


Groups > linux.kernel > #1496535

[PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in setup_conf()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in setup_conf()
Date 2016-10-06 11:50 +0200
Message-ID <spdto-6Li-31@gated-at.bofh.it> (permalink)
References <qEuGl-43C-5@gated-at.bofh.it> <spcH0-6dt-53@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 17:46:02 +0200

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Delete a repeated check for the local variable "conf"
  which became unnecessary with this refactoring.

* Reorder calls for the functions "kfree" and "safe_put_page"
  at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 8326e68..abe75c2 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3501,7 +3501,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	err = -ENOMEM;
 	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (!conf)
-		goto out;
+		return ERR_PTR(-ENOMEM);
 
 	/* FIXME calc properly */
 	conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
@@ -3554,12 +3554,10 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	return conf;
 
  out:
-	if (conf) {
-		mempool_destroy(conf->r10bio_pool);
-		kfree(conf->mirrors);
-		safe_put_page(conf->tmppage);
-		kfree(conf);
-	}
+	mempool_destroy(conf->r10bio_pool);
+	safe_put_page(conf->tmppage);
+	kfree(conf->mirrors);
+	kfree(conf);
 	return ERR_PTR(err);
 }
 
-- 
2.10.1

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


Thread

MD-RAID: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
  [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher  level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
  [PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
  [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
  [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function  names SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
  [PATCH 43/54] md/raid10: Return directly after detection of  unsupported settings in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 42/54] md/raid10: Delete an error message for a failed memory  allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 46/54] md/raid10: Less function calls in setup_conf() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 47/54] md/raid10: Improve another size determination in  raid10_start_reshape() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 41/54] md/raid10: Improve another size determination in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 45/54] md/raid10: Move assignments for the variable "err" in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces Joe Perches <coupons@perches.com> - 2016-10-06 18:40 +0200
      Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 19:30 +0200
        Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces Joe Perches <joe@perches.com> - 2016-10-06 19:40 +0200
          Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:10 +0200
            Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces Joe Perches <joe@perches.com> - 2016-10-06 20:20 +0200
              Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:40 +0200
  [PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
  [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
  [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in  raid10_status() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
  [PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
  [PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
  [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200

csiph-web