RAS: two fixlets
Subsystems (2)
Borislav Petkov
maintainercover RAS: two fixlets
From: Borislav Petkov <[email protected]>
Hi guys,
just minor stuff right now. Please queue.
Thx.
Borislav Petkov (1):
x86/mce: Hide mca_cfg
Nicolas Iooss (1):
RAS/CEC: Use the right length for "cec_disable"
arch/x86/include/asm/mce.h | 1 - arch/x86/kernel/cpu/mcheck/mce-internal.h | 7 +++++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 ++ drivers/ras/cec.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.13.0
Borislav Petkov
maintainerPATCH 1/2 RAS/CEC: Use the right length for "cec_disable"
From: Nicolas Iooss <[email protected]>
parse_cec_param() compares a string with "cec_disable" using only 7 characters of the 11-character-long string. Fix the length.
--- drivers/ras/cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ras/cec.c +1 -1
@@ -523,7 +523,7 @@ int __init parse_cec_param(char *str)if (*str =='=' ) str++; -if (!strncmp (str,"cec_disable" ,7 )) +if (!strncmp (str,"cec_disable" ,11 )) ce_arr.disabled =1 ;else return 0 ;
Signature · 1 line
2.13.0
Re: [PATCH 1/2] RAS/CEC: Use the right length for "cec_disable"
Quoted 18 lines · Borislav Petkov
From: Nicolas Iooss <[email protected]>
parse_cec_param()compares a string with "cec_disable" using only 7 characters of the 11-character-long string. Fix the length.Signed-off-by Nicolas Iooss <[email protected]>Fixes 011d82611172 ("RAS: Add a Corrected Errors Collector")Signed-off-by Borislav Petkov <[email protected]>--- drivers/ras/cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ras/cec.c +0
-0
drivers/ras/cec.c int __init parse_cec_param(char *str) · line 526
Quoted 5 lines
drivers/ras/cec.c +1
-1@@ -523,7 +523,7 @@ int __init parse_cec_param(char *str)if (*str =='=' ) str++; -if (!strncmp (str,"cec_disable" ,7 )) +if (!strncmp (str,"cec_disable" ,11 ))
This kind of issue happens over and over. So if you really want to use strncmp() then this should be:
#define CEC_DISABLE "cec_disable"
if (!strncmp(str, CEC_DISABLE, strlen(CEC_DISABLE))
or we get a proper helper for that. Though in case of comparing some string against a constant string strncmp() has no real advantage over strcmp() as the comparison is guaranteed to be bound by the string constant.
Thanks,
tglx
Borislav Petkov
maintainerRe: [PATCH 1/2] RAS/CEC: Use the right length for "cec_disable"
Quoted 28 lines · Thomas Gleixner
Quoted 18 lines · Borislav Petkov
From: Nicolas Iooss <[email protected]>
parse_cec_param()compares a string with "cec_disable" using only 7 characters of the 11-character-long string. Fix the length.Signed-off-by Nicolas Iooss <[email protected]>Fixes 011d82611172 ("RAS: Add a Corrected Errors Collector")Signed-off-by Borislav Petkov <[email protected]>--- drivers/ras/cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ras/cec.c +0
-0drivers/ras/cec.c int __init parse_cec_param(char *str) · line 526
Quoted 5 lines
drivers/ras/cec.c +1
-1@@ -523,7 +523,7 @@ int __init parse_cec_param(char *str)if (*str =='=' ) str++; -if (!strncmp (str,"cec_disable" ,7 )) +if (!strncmp (str,"cec_disable" ,11 ))This kind of issue happens over and over. So if you really want to use
strncmp()then this should be:
Quoted 7 lines
#define
CEC_DISABLE"cec_disable"if (!strncmp(str,
CEC_DISABLE,strlen(CEC_DISABLE))or we get a proper helper for that. Though in case of comparing some string against a constant string
strncmp()has no real advantage overstrcmp()as the comparison is guaranteed to be bound by the string constant.
Right.
Nicolas, wanna address that?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH 1/2] RAS/CEC: Use the right length for "cec_disable"
Quoted 37 lines · Borislav Petkov
Quoted 28 lines · Thomas Gleixner
Quoted 18 lines · Borislav Petkov
From: Nicolas Iooss <[email protected]>
parse_cec_param()compares a string with "cec_disable" using only 7 characters of the 11-character-long string. Fix the length.Signed-off-by Nicolas Iooss <[email protected]>Fixes 011d82611172 ("RAS: Add a Corrected Errors Collector")Signed-off-by Borislav Petkov <[email protected]>--- drivers/ras/cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ras/cec.c +0
-0drivers/ras/cec.c int __init parse_cec_param(char *str) · line 526
Quoted 5 lines
drivers/ras/cec.c +1
-1@@ -523,7 +523,7 @@ int __init parse_cec_param(char *str)if (*str =='=' ) str++; -if (!strncmp (str,"cec_disable" ,7 )) +if (!strncmp (str,"cec_disable" ,11 ))This kind of issue happens over and over. So if you really want to use
strncmp()then this should be:Quoted 7 lines
#define
CEC_DISABLE"cec_disable"if (!strncmp(str,
CEC_DISABLE,strlen(CEC_DISABLE))or we get a proper helper for that. Though in case of comparing some string against a constant string
strncmp()has no real advantage overstrcmp()as the comparison is guaranteed to be bound by the string constant.
Quoted 5 lines
Right.
Nicolas, wanna address that?
Thx.
Hi, the only difference I see between strncmp+strlen and strcmp is that the first option compares a prefix ("does the string begin with cec_disable?") and the second one checks that strings are equals. In parse_cec_param() it does not seem to matter.
I have seen that Thomas Gleixner has already committed a modified patch which uses strcmp(), which looks good to me.
Thanks!
Nicolas
Borislav Petkov
maintainerPATCH 2/2 x86/mce: Hide mca_cfg
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Now that lguest is gone, put it in the internal header which should be used only by MCA/RAS code.
Add missing header guards while at it.
No functionality change.
--- arch/x86/include/asm/mce.h | 1 - arch/x86/kernel/cpu/mcheck/mce-internal.h | 7 +++++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)
arch/x86/include/asm/mce.h +0 -1
@@ -187,7 +187,6 @@ struct mca_msr_regs {extern struct mce_vendor_flags mce_flags; -extern struct mca_config mca_cfg;extern struct mca_msr_regs msr_ops;enum mce_notifier_prios {
arch/x86/kernel/cpu/mcheck/mce-internal.h +7 -0
@@ -1,3 +1,6 @@ +#ifndef __X86_MCE_INTERNAL_H__ +#define __X86_MCE_INTERNAL_H__ +#include <linux/device.h> #include <asm/mce.h>
@@ -108,3 +111,7 @@ static inline void mce_work_trigger(void) { }static inline void mce_register_injector_chain (struct notifier_block *nb) { }static inline void mce_unregister_injector_chain (struct notifier_block *nb) { }#endif + +extern struct mca_config mca_cfg; + +#endif /* __X86_MCE_INTERNAL_H__ */
arch/x86/kernel/cpu/mcheck/mce_amd.c +2 -0
@@ -28,6 +28,8 @@#include <asm/msr.h> #include <asm/trace/irq_vectors.h> +#include "mce-internal.h" +#define NR_BLOCKS 5#define THRESHOLD_MAX 0xFFF#define INT_TYPE_APIC 0x00020000
Signature · 1 line
2.13.0
tip-bot for Borislav Petkov
merge bot[tip:ras/urgent] x86/mce: Hide mca_cfg
x86/mce: Hide mca_cfg
Commit-ID: 262e681183ddcdb24d64a2f993e41a226adcec29 Gitweb: https://git.kernel.org/tip/262e681183ddcdb24d64a2f993e41a226adcec29 Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 2 Oct 2017 11:28:36 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 5 Oct 2017 14:23:06 +0200
x86/mce: Hide mca_cfg
Now that lguest is gone, put it in the internal header which should be used only by MCA/RAS code.
Add missing header guards while at it.
No functional change.
--- arch/x86/include/asm/mce.h | 1 - arch/x86/kernel/cpu/mcheck/mce-internal.h | 7 +++++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)
arch/x86/include/asm/mce.h +0 -1
@@ -187,7 +187,6 @@ struct mca_msr_regs {extern struct mce_vendor_flags mce_flags; -extern struct mca_config mca_cfg;extern struct mca_msr_regs msr_ops;enum mce_notifier_prios {
arch/x86/kernel/cpu/mcheck/mce-internal.h +7 -0
@@ -1,3 +1,6 @@ +#ifndef __X86_MCE_INTERNAL_H__ +#define __X86_MCE_INTERNAL_H__ +#include <linux/device.h> #include <asm/mce.h>
@@ -108,3 +111,7 @@ static inline void mce_work_trigger(void) { }static inline void mce_register_injector_chain (struct notifier_block *nb) { }static inline void mce_unregister_injector_chain (struct notifier_block *nb) { }#endif + +extern struct mca_config mca_cfg; + +#endif /* __X86_MCE_INTERNAL_H__ */
arch/x86/kernel/cpu/mcheck/mce_amd.c +2 -0
@@ -28,6 +28,8 @@#include <asm/msr.h> #include <asm/trace/irq_vectors.h> +#include "mce-internal.h" +#define NR_BLOCKS 5#define THRESHOLD_MAX 0xFFF#define INT_TYPE_APIC 0x00020000