Skip to contentSkip to conversation

dm: Return correct value in retry loop

PATCH In review Minfei Huang 2 participants 3 messages Sep 6, 2016 – Sep 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: Return correct value in retry loop

dm_resume will return sliently in retry loop's failure. Assign a correct return value in the failed loop.

Remove a useless assignment as well.

---
 drivers/md/dm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm.c +2 -3
index fa9b1cb..c935cc8 100644
@@ -2249,10 +2249,11 @@ static int __dm_resume(struct mapped_device *md, struct dm_table *map)
 
 int dm_resume(struct mapped_device *md)
 {
-	int r = -EINVAL;
+	int r;
 	struct dm_table *map = NULL;
 
 retry:
+	r = -EINVAL;
 	mutex_lock_nested(&md->suspend_lock, SINGLE_DEPTH_NESTING);
 
 	if (!dm_suspended_md(md))
@@ -2277,10 +2278,8 @@ retry:
 
 	clear_bit(DMF_SUSPENDED, &md->flags);
 
-	r = 0;
 out:
 	mutex_unlock(&md->suspend_lock);
-
 	return r;
 }
 
Signature · 1 line
2.7.4 (Apple Git-66)
#1 lore raw

Ping.

Any comment is appreciate.

Thanks
Minfei

Quoted 41 lines · Minfei Huang

dm_resume will return sliently in retry loop's failure. Assign a correct return value in the failed loop.

Remove a useless assignment as well.

---
 drivers/md/dm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm.c +2 -3
index fa9b1cb..c935cc8 100644
@@ -2249,10 +2249,11 @@ static int __dm_resume(struct mapped_device *md, struct dm_table *map)
 
 int dm_resume(struct mapped_device *md)
 {
-	int r = -EINVAL;
+	int r;
 	struct dm_table *map = NULL;
 
 retry:
+	r = -EINVAL;
 	mutex_lock_nested(&md->suspend_lock, SINGLE_DEPTH_NESTING);
 
 	if (!dm_suspended_md(md))
@@ -2277,10 +2278,8 @@ retry:
 
 	clear_bit(DMF_SUSPENDED, &md->flags);
 
-	r = 0;
 out:
 	mutex_unlock(&md->suspend_lock);
-
 	return r;
 }
 
Signature · 1 line
2.7.4 (Apple Git-66)
#2 lore raw

Thanks for the patch, I've picked it up as a stable@ fix for either 4.8-rc7 or when the 4.9 merge windw opens (I'm leaning toward the latter since this issue has been around since 3.19 was released and there aren't any known problems/reports related to this oversight).

Please see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.8&id=7735f936a13d79bbaead1723e4532e65d4c4cf01

Quoted 54 lines · Minfei Huang

Ping.

Any comment is appreciate.

Thanks
Minfei

Quoted 41 lines · Minfei Huang

dm_resume will return sliently in retry loop's failure. Assign a correct return value in the failed loop.

Remove a useless assignment as well.

---
 drivers/md/dm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm.c +2 -3
index fa9b1cb..c935cc8 100644
@@ -2249,10 +2249,11 @@ static int __dm_resume(struct mapped_device *md, struct dm_table *map)
 
 int dm_resume(struct mapped_device *md)
 {
-	int r = -EINVAL;
+	int r;
 	struct dm_table *map = NULL;
 
 retry:
+	r = -EINVAL;
 	mutex_lock_nested(&md->suspend_lock, SINGLE_DEPTH_NESTING);
 
 	if (!dm_suspended_md(md))
@@ -2277,10 +2278,8 @@ retry:
 
 	clear_bit(DMF_SUSPENDED, &md->flags);
 
-	r = 0;
 out:
 	mutex_unlock(&md->suspend_lock);
-
 	return r;
 }
 
Signature · 1 line
2.7.4 (Apple Git-66)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel