Skip to contentSkip to conversation

bdi: fix cleanup when fail to percpu_counter_init

PATCH In review weiping zhang 3 participants 5 messages Sep 15, 2017 – Sep 19, 2017

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

PATCH 1/1 bdi: fix cleanup when fail to percpu_counter_init

when percpu_counter_init fail at i, 0 ~ (i-1) should be destoried, not 1 ~ i.

---
 mm/backing-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +1 -1
index e19606b..d399d3c 100644
@@ -334,7 +334,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
 	return 0;
 
 out_destroy_stat:
-	while (i--)
+	while (--i >= 0)
 		percpu_counter_destroy(&wb->stat[i]);
 	fprop_local_destroy_percpu(&wb->completions);
 out_put_cong:
Signature · 7 lines
2.9.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · weiping zhang

when percpu_counter_init fail at i, 0 ~ (i-1) should be destoried, not 1 ~ i.

Good catch. You can add:

Honza

Quoted 20 lines
---
 mm/backing-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +1 -1
index e19606b..d399d3c 100644
@@ -334,7 +334,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
 	return 0;
 
 out_destroy_stat:
-	while (i--)
+	while (--i >= 0)
 		percpu_counter_destroy(&wb->stat[i]);
 	fprop_local_destroy_percpu(&wb->completions);
 out_put_cong:
Signature · 1 line
2.9.4
Signature · 8 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
In reply to weiping zhang
Quoted 13 lines · weiping zhang

when percpu_counter_init fail at i, 0 ~ (i-1) should be destoried, not 1 ~ i.

---
 mm/backing-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +0 -0
index e19606b..d399d3c 100644

mm/backing-dev.c static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, · line 337

Quoted 5 lines
mm/backing-dev.c +1 -1
@@ -334,7 +334,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
 	return 0;
 
 out_destroy_stat:
-	while (i--)
+	while (--i >= 0)

These two constructs will produce identical results.

Signature · 7 lines
Jens Axboe

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 16 lines · Jens Axboe
Quoted 15 lines · weiping zhang

when percpu_counter_init fail at i, 0 ~ (i-1) should be destoried, not 1 ~ i.

---
 mm/backing-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +0 -0
index e19606b..d399d3c 100644
@@ -334,7 +334,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
 	return 0;
 
Quoted 5 lines

mm/backing-dev.c static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, · line 337

Quoted 3 lines
mm/backing-dev.c +1 -1
 out_destroy_stat:
-	while (i--)
+	while (--i >= 0)

These two constructs will produce identical results.

Bah, you are correct. I got confused.

Honza

Signature · 8 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw
Quoted 17 lines · Jan Kara
Quoted 16 lines · Jens Axboe
Quoted 15 lines · weiping zhang

when percpu_counter_init fail at i, 0 ~ (i-1) should be destoried, not 1 ~ i.

---
 mm/backing-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/backing-dev.c +0 -0
index e19606b..d399d3c 100644
@@ -334,7 +334,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
 	return 0;
 
Quoted 8 lines
Quoted 5 lines

mm/backing-dev.c static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, · line 337

Quoted 3 lines
mm/backing-dev.c +1 -1
 out_destroy_stat:
-	while (i--)
+	while (--i >= 0)

These two constructs will produce identical results.

Bah, you are correct. I got confused.

It's my fault, thanks all of you, ^_^

weiping

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>