Re: [PATCH 12/12] md-cluster: handle error situations more precisely in lockres_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 07/10/2015 04:01 AM, Guoqing Jiang wrote:
In lockres_init, it's better to distinguish different err conditions.

Signed-off-by: Guoqing Jiang <gqjiang@xxxxxxxx>

This is not required. kfree() is capable of ignoring null pointers.


---
  drivers/md/md-cluster.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index c35a03a..54d225c 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -131,14 +131,14 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
  	res->name = kzalloc(namelen + 1, GFP_KERNEL);
  	if (!res->name) {
  		pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name);
-		goto out_err;
+		goto out_err_name;
  	}
  	strlcpy(res->name, name, namelen + 1);
  	if (with_lvb) {
  		res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL);
  		if (!res->lksb.sb_lvbptr) {
  			pr_err("md-cluster: Unable to allocate LVB for resource %s\n", name);
-			goto out_err;
+			goto out_err_lvb;
  		}
  		res->flags = DLM_LKF_VALBLK;
  	}
@@ -159,7 +159,9 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
  	return res;
  out_err:
  	kfree(res->lksb.sb_lvbptr);
+out_err_lvb:
  	kfree(res->name);
+out_err_name:
  	kfree(res);
  	return NULL;
  }
@@ -627,7 +629,6 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
  	char str[64];
  	sector_t lo, hi;

-
  	for (i = 0; i < total_slots; i++) {
  		memset(str, '\0', 64);
  		snprintf(str, 64, "bitmap%04d", i);


--
Goldwyn
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux