kernel/padata.c: always check the return value of __padata_remove_cpu() and __padata_add_cpu()
Subsystems (2)
PATCH 1/1 kernel/padata.c: always check the return value of __padata_remove_cpu() and __padata_add_cpu()
When failure occures, __padata_add_cpu() and __padata_remove_cpu() will return -ENOMEM, which need be noticed in any cases (even in cleaning up cases).
--- kernel/padata.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
kernel/padata.c +6 -2
@@ -871,16 +871,20 @@ static int padata_cpu_callback(struct notifier_block *nfb,if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock); -__padata_remove_cpu (pinst, cpu); + err =__padata_remove_cpu (pinst, cpu);mutex_unlock (&pinst->lock); +if (err) +return notifier_from_errno (err);case CPU_DOWN_FAILED :case CPU_DOWN_FAILED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock); -__padata_add_cpu (pinst, cpu); + err =__padata_add_cpu (pinst, cpu);mutex_unlock (&pinst->lock); +if (err) +return notifier_from_errno (err); }return NOTIFY_OK ;
Signature · 1 line
1.7.7.6
If this patch is correct, better to let CPU_ONLINE and CPU_DOWN_FAILED share the same code.
And do we need a comment "/* fall through */" between CPU_UP_CANCELED and CPU_DOWN_FAILED (or it is another bug, need a 'break' statement) ?
At last, also better to let CPU_DOWN_PREPARE and CPU_UP_CANCELED share the same code (if need a 'break'), or share the most of code (if "fall through").
Thanks.
Quoted 37 lines · Chen Gang
When failure occures,
__padata_add_cpu()and__padata_remove_cpu()will return-ENOMEM, which need be noticed in any cases (even in cleaning up cases).Signed-off-by Chen Gang <[email protected]>--- kernel/padata.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)kernel/padata.c +6
-2@@ -871,16 +871,20 @@ static int padata_cpu_callback(struct notifier_block *nfb,if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock); -__padata_remove_cpu (pinst, cpu); + err =__padata_remove_cpu (pinst, cpu);mutex_unlock (&pinst->lock); +if (err) +return notifier_from_errno (err);case CPU_DOWN_FAILED :case CPU_DOWN_FAILED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock); -__padata_add_cpu (pinst, cpu); + err =__padata_add_cpu (pinst, cpu);mutex_unlock (&pinst->lock); +if (err) +return notifier_from_errno (err); }return NOTIFY_OK ;
Signature · 1 line
Chen Gang
Steffen Klassert
maintainerQuoted 11 lines · Chen Gang
If this patch is correct, better to let
CPU_ONLINEandCPU_DOWN_FAILEDshare the same code.And do we need a comment "/* fall through */" between
CPU_UP_CANCELEDandCPU_DOWN_FAILED(or it is another bug, need a 'break' statement) ?At last, also better to let
CPU_DOWN_PREPAREandCPU_UP_CANCELEDshare the same code (if need a 'break'), or share the most of code (if "fall through").
CPU_ONLINE and CPU_DOWN_FAILED can share the code. Same is true for CPU_DOWN_PREPARE and CPU_UP_CANCELED.
Thanks!
Quoted 13 lines · Steffen Klassert
Quoted 11 lines · Chen Gang
If this patch is correct, better to let
CPU_ONLINEandCPU_DOWN_FAILEDshare the same code.And do we need a comment "/* fall through */" between
CPU_UP_CANCELEDandCPU_DOWN_FAILED(or it is another bug, need a 'break' statement) ?At last, also better to let
CPU_DOWN_PREPAREandCPU_UP_CANCELEDshare the same code (if need a 'break'), or share the most of code (if "fall through").
Quoted 6 lines
CPU_ONLINEandCPU_DOWN_FAILEDcan share the code. Same is true forCPU_DOWN_PREPAREandCPU_UP_CANCELED.Thanks!
Thank you too.
And need I send another patch for it ?
Or just make by yourself (and better to mark me as Reported-by). :-)
Thanks.
Signature · 1 line
Chen Gang
Steffen Klassert
maintainerQuoted 21 lines · Chen Gang
Quoted 13 lines · Steffen Klassert
Quoted 11 lines · Chen Gang
If this patch is correct, better to let
CPU_ONLINEandCPU_DOWN_FAILEDshare the same code.And do we need a comment "/* fall through */" between
CPU_UP_CANCELEDandCPU_DOWN_FAILED(or it is another bug, need a 'break' statement) ?At last, also better to let
CPU_DOWN_PREPAREandCPU_UP_CANCELEDshare the same code (if need a 'break'), or share the most of code (if "fall through").Quoted 6 lines
CPU_ONLINEandCPU_DOWN_FAILEDcan share the code. Same is true forCPU_DOWN_PREPAREandCPU_UP_CANCELED.Thanks!
Quoted 6 lines
Thank you too.
And need I send another patch for it ?
Or just make by yourself (and better to mark me as Reported-by). :-)
You found the problem, feel free to send a patch.
PATCH v2 1/1 kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
Share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED.
It will fix 2 bugs:
"not check the return value of __padata_remove_cpu() and __padata_add_cpu()". "need add 'break' between CPU_UP_CANCELED and CPU_DOWN_FAILED".
--- kernel/padata.c | 20 ++++---------------- 1 files changed, 4 insertions(+), 16 deletions(-)
kernel/padata.c +4 -16
@@ -846,6 +846,8 @@ static int padata_cpu_callback(struct notifier_block *nfb,switch (action) {case CPU_ONLINE :case CPU_ONLINE_FROZEN : +case CPU_DOWN_FAILED : +case CPU_DOWN_FAILED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock);
@@ -857,6 +859,8 @@ static int padata_cpu_callback(struct notifier_block *nfb,case CPU_DOWN_PREPARE :case CPU_DOWN_PREPARE_FROZEN : +case CPU_UP_CANCELED : +case CPU_UP_CANCELED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock);
@@ -865,22 +869,6 @@ static int padata_cpu_callback(struct notifier_block *nfb,if (err)return notifier_from_errno (err);break ; - -case CPU_UP_CANCELED : -case CPU_UP_CANCELED_FROZEN : -if (!pinst_has_cpu (pinst, cpu)) -break ; -mutex_lock (&pinst->lock); -__padata_remove_cpu (pinst, cpu); -mutex_unlock (&pinst->lock); - -case CPU_DOWN_FAILED : -case CPU_DOWN_FAILED_FROZEN : -if (!pinst_has_cpu (pinst, cpu)) -break ; -mutex_lock (&pinst->lock); -__padata_add_cpu (pinst, cpu); -mutex_unlock (&pinst->lock); }return NOTIFY_OK ;
Signature · 1 line
1.7.7.6
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
Quoted 8 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".
Do we need more details descriptions ?
If so, could Steffen give more expert details information ?
Thanks.
Quoted 52 lines
Signed-off-by Chen Gang <[email protected]>--- kernel/padata.c | 20 ++++---------------- 1 files changed, 4 insertions(+), 16 deletions(-)kernel/padata.c +4
-16@@ -846,6 +846,8 @@ static int padata_cpu_callback(struct notifier_block *nfb,switch (action) {case CPU_ONLINE :case CPU_ONLINE_FROZEN : +case CPU_DOWN_FAILED : +case CPU_DOWN_FAILED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock);@@ -857,6 +859,8 @@ static int padata_cpu_callback(struct notifier_block *nfb,case CPU_DOWN_PREPARE :case CPU_DOWN_PREPARE_FROZEN : +case CPU_UP_CANCELED : +case CPU_UP_CANCELED_FROZEN :if (!pinst_has_cpu (pinst, cpu))break ;mutex_lock (&pinst->lock);@@ -865,22 +869,6 @@ static int padata_cpu_callback(struct notifier_block *nfb,if (err)return notifier_from_errno (err);break ; - -case CPU_UP_CANCELED : -case CPU_UP_CANCELED_FROZEN : -if (!pinst_has_cpu (pinst, cpu)) -break ; -mutex_lock (&pinst->lock); -__padata_remove_cpu (pinst, cpu); -mutex_unlock (&pinst->lock); - -case CPU_DOWN_FAILED : -case CPU_DOWN_FAILED_FROZEN : -if (!pinst_has_cpu (pinst, cpu)) -break ; -mutex_lock (&pinst->lock); -__padata_add_cpu (pinst, cpu); -mutex_unlock (&pinst->lock); }return NOTIFY_OK ;
Signature · 1 line
Chen Gang
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
In reply to Chen GangQuoted 10 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".Signed-off-by Chen Gang <[email protected]>
This looks ok to me, Herbert can you take this one?
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
Quoted 6 lines · Steffen Klassert
Quoted 5 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
Quoted 7 lines
Quoted 5 lines
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".Signed-off-by Chen Gang <[email protected]>This looks ok to me, Herbert can you take this one?
Sure.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
Quoted 11 lines · Herbert Xu
Quoted 10 lines · Steffen Klassert
Quoted 9 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Chen Gang <[email protected]>This looks ok to me, Herbert can you take this one?
Sure.
Thank you all.
Quoted 2 lines
Thanks,
Thanks.
Signature · 1 line
Chen Gang
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
In reply to Steffen KlassertQuoted 10 lines · Steffen Klassert
Quoted 9 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".
Quoted 5 lines
Quoted 1 line
Signed-off-by Chen Gang <[email protected]>This looks ok to me, Herbert can you take this one?
Acked-by Steffen Klassert <[email protected]>
Patch applied. Thanks!
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v2] kernel/padata.c: share code between CPU_ONLINE and CPU_DOWN_FAILED, same to CPU_DOWN_PREPARE and CPU_UP_CANCELED
Quoted 11 lines · Herbert Xu
Quoted 10 lines · Steffen Klassert
Quoted 9 lines · Chen Gang
Share code between
CPU_ONLINEandCPU_DOWN_FAILED, same toCPU_DOWN_PREPAREandCPU_UP_CANCELED.It will fix 2 bugs:
"not check the return value of
__padata_remove_cpu()and__padata_add_cpu()". "need add 'break' betweenCPU_UP_CANCELEDandCPU_DOWN_FAILED".
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Chen Gang <[email protected]>This looks ok to me, Herbert can you take this one?
Acked-by Steffen Klassert <[email protected]>Patch applied. Thanks!
Thank you too.
Signature · 1 line
Chen Gang
Quoted 22 lines · Steffen Klassert
Quoted 21 lines · Chen Gang
Quoted 19 lines · Steffen Klassert
Quoted 11 lines · Chen Gang
If this patch is correct, better to let
CPU_ONLINEandCPU_DOWN_FAILEDshare the same code.And do we need a comment "/* fall through */" between
CPU_UP_CANCELEDandCPU_DOWN_FAILED(or it is another bug, need a 'break' statement) ?At last, also better to let
CPU_DOWN_PREPAREandCPU_UP_CANCELEDshare the same code (if need a 'break'), or share the most of code (if "fall through").
CPU_ONLINEandCPU_DOWN_FAILEDcan share the code. Same is true forCPU_DOWN_PREPAREandCPU_UP_CANCELED.Thanks!
Quoted 10 lines
Quoted 6 lines
Thank you too.
And need I send another patch for it ?
Or just make by yourself (and better to mark me as Reported-by). :-)
You found the problem, feel free to send a patch.
Thanks, I will send patch v2 for it.
Signature · 1 line
Chen Gang