* [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() @ 2021-08-31 9:57 Jackie Liu 2021-09-01 12:09 ` Krzysztof Kozlowski 0 siblings, 1 reply; 6+ messages in thread From: Jackie Liu @ 2021-08-31 9:57 UTC (permalink / raw) To: krzysztof.kozlowski; +Cc: linux-samsung-soc, liuyun01 From: Jackie Liu <liuyun01@kylinos.cn> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. let's add an error pointer check in s3c24xx_handle_irq. Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> --- arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c index 0c631c14a817..d58bf0f9bf9a 100644 --- a/arch/arm/mach-s3c/irq-s3c24xx.c +++ b/arch/arm/mach-s3c/irq-s3c24xx.c @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) { do { - if (likely(s3c_intc[0])) + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) continue; - if (s3c_intc[2]) + if (!IS_ERR_OR_NULL(s3c_intc[2])) if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) continue; -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() 2021-08-31 9:57 [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() Jackie Liu @ 2021-09-01 12:09 ` Krzysztof Kozlowski 2021-09-01 12:28 ` Jackie Liu 0 siblings, 1 reply; 6+ messages in thread From: Krzysztof Kozlowski @ 2021-09-01 12:09 UTC (permalink / raw) To: Jackie Liu; +Cc: linux-samsung-soc, liuyun01 On 31/08/2021 11:57, Jackie Liu wrote: > From: Jackie Liu <liuyun01@kylinos.cn> > > The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. > let's add an error pointer check in s3c24xx_handle_irq. > > Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") > Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> Please use scripts/get_maintainers.pl to get list of mailing lists to CC. You skipped two - arm and LKML. > --- > arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c > index 0c631c14a817..d58bf0f9bf9a 100644 > --- a/arch/arm/mach-s3c/irq-s3c24xx.c > +++ b/arch/arm/mach-s3c/irq-s3c24xx.c > @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, > static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) > { > do { > - if (likely(s3c_intc[0])) > + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) > if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) Thanks for the patch but it does not look entirely correct. For platform based machines, neither ERR nor NULL can happen here. The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: s3c_intc[0] = s3c24xx_init_intc() If this fails, the next calls to s3c24xx_init_intc() won't be executed. For DT machine, s3c_init_intc_of() could set the IRQ handler without setting s3c_intc[0] only if it was called with num_ctrl=0. There is no such code path, so again the s3c_intc[0] will have a valid pointer if set_handle_irq() is called. Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. The code can be simplified by removing if(), if we really wanted and were sure about it. > continue; > > - if (s3c_intc[2]) > + if (!IS_ERR_OR_NULL(s3c_intc[2])) For the non-DT case, this seems ugly but proper solution. The s3c_intc[2] could be NULL (not set at all) or set as ERR (if s3c24xx_init_intc() fails). > if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) > continue; > > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() 2021-09-01 12:09 ` Krzysztof Kozlowski @ 2021-09-01 12:28 ` Jackie Liu 0 siblings, 0 replies; 6+ messages in thread From: Jackie Liu @ 2021-09-01 12:28 UTC (permalink / raw) To: Krzysztof Kozlowski, Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 4351 bytes --] Hi Krzysztof, Thanks for you message. å¨ 2021/9/1 ä¸å8:09, Krzysztof Kozlowski åé: > On 31/08/2021 11:57, Jackie Liu wrote: >> From: Jackie Liu <liuyun01@kylinos.cn> >> >> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. >> let's add an error pointer check in s3c24xx_handle_irq. >> >> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") >> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> > > Please use scripts/get_maintainers.pl to get list of mailing lists to > CC. You skipped two - arm and LKML. > >> --- >> arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c >> index 0c631c14a817..d58bf0f9bf9a 100644 >> --- a/arch/arm/mach-s3c/irq-s3c24xx.c >> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c >> @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, >> static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) >> { >> do { >> - if (likely(s3c_intc[0])) >> + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) >> if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) > > Thanks for the patch but it does not look entirely correct. > > For platform based machines, neither ERR nor NULL can happen here. > The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: > s3c_intc[0] = s3c24xx_init_intc() > > If this fails, the next calls to s3c24xx_init_intc() won't be executed. > > For DT machine, s3c_init_intc_of() could set the IRQ handler without > setting s3c_intc[0] only if it was called with num_ctrl=0. There is no > such code path, so again the s3c_intc[0] will have a valid pointer if > set_handle_irq() is called. > > Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. > > The code can be simplified by removing if(), if we really wanted and > were sure about it. In fact, I didn't study his underlying logic in depth, but found that this place was not particularly perfect based on the return value of the function, because I happened to encounter a similar problem elsewhere. > > >> continue; >> >> - if (s3c_intc[2]) >> + if (!IS_ERR_OR_NULL(s3c_intc[2])) > > For the non-DT case, this seems ugly but proper solution. The > s3c_intc[2] could be NULL (not set at all) or set as ERR (if > s3c24xx_init_intc() fails). > >> if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) >> continue; >> >> > > > Best regards, > Krzysztof > Would you mind review v2? -------------------------------------------------------------- diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c index 0c631c14a817..df471d322493 100644 --- a/arch/arm/mach-s3c/irq-s3c24xx.c +++ b/arch/arm/mach-s3c/irq-s3c24xx.c @@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) { do { - if (likely(s3c_intc[0])) - if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) - continue; + /* For platform based machines, neither ERR nor NULL can happen here. + * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: + * + * s3c_intc[0] = s3c24xx_init_intc() + * + * If this fails, the next calls to s3c24xx_init_intc() won't be executed. + * + * For DT machine, s3c_init_intc_of() could set the IRQ handler without + * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no + * such code path, so again the s3c_intc[0] will have a valid pointer if + * set_handle_irq() is called. + * + * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. + */ + if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) + continue; - if (s3c_intc[2]) + if (!IS_ERR_OR_NULL(s3c_intc[2])) if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) continue; --- Thanks, Jackie ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() @ 2021-09-01 12:28 ` Jackie Liu 0 siblings, 0 replies; 6+ messages in thread From: Jackie Liu @ 2021-09-01 12:28 UTC (permalink / raw) To: Krzysztof Kozlowski, Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel [-- Attachment #1: Type: text/plain, Size: 4351 bytes --] Hi Krzysztof, Thanks for you message. å¨ 2021/9/1 ä¸å8:09, Krzysztof Kozlowski åé: > On 31/08/2021 11:57, Jackie Liu wrote: >> From: Jackie Liu <liuyun01@kylinos.cn> >> >> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. >> let's add an error pointer check in s3c24xx_handle_irq. >> >> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") >> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> > > Please use scripts/get_maintainers.pl to get list of mailing lists to > CC. You skipped two - arm and LKML. > >> --- >> arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c >> index 0c631c14a817..d58bf0f9bf9a 100644 >> --- a/arch/arm/mach-s3c/irq-s3c24xx.c >> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c >> @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, >> static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) >> { >> do { >> - if (likely(s3c_intc[0])) >> + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) >> if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) > > Thanks for the patch but it does not look entirely correct. > > For platform based machines, neither ERR nor NULL can happen here. > The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: > s3c_intc[0] = s3c24xx_init_intc() > > If this fails, the next calls to s3c24xx_init_intc() won't be executed. > > For DT machine, s3c_init_intc_of() could set the IRQ handler without > setting s3c_intc[0] only if it was called with num_ctrl=0. There is no > such code path, so again the s3c_intc[0] will have a valid pointer if > set_handle_irq() is called. > > Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. > > The code can be simplified by removing if(), if we really wanted and > were sure about it. In fact, I didn't study his underlying logic in depth, but found that this place was not particularly perfect based on the return value of the function, because I happened to encounter a similar problem elsewhere. > > >> continue; >> >> - if (s3c_intc[2]) >> + if (!IS_ERR_OR_NULL(s3c_intc[2])) > > For the non-DT case, this seems ugly but proper solution. The > s3c_intc[2] could be NULL (not set at all) or set as ERR (if > s3c24xx_init_intc() fails). > >> if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) >> continue; >> >> > > > Best regards, > Krzysztof > Would you mind review v2? -------------------------------------------------------------- diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c index 0c631c14a817..df471d322493 100644 --- a/arch/arm/mach-s3c/irq-s3c24xx.c +++ b/arch/arm/mach-s3c/irq-s3c24xx.c @@ -362,11 +362,24 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) { do { - if (likely(s3c_intc[0])) - if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) - continue; + /* For platform based machines, neither ERR nor NULL can happen here. + * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: + * + * s3c_intc[0] = s3c24xx_init_intc() + * + * If this fails, the next calls to s3c24xx_init_intc() won't be executed. + * + * For DT machine, s3c_init_intc_of() could set the IRQ handler without + * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no + * such code path, so again the s3c_intc[0] will have a valid pointer if + * set_handle_irq() is called. + * + * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. + */ + if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) + continue; - if (s3c_intc[2]) + if (!IS_ERR_OR_NULL(s3c_intc[2])) if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) continue; --- Thanks, Jackie [-- Attachment #2: Type: text/plain, Size: 176 bytes --] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() 2021-09-01 12:28 ` Jackie Liu @ 2021-09-01 12:31 ` Krzysztof Kozlowski -1 siblings, 0 replies; 6+ messages in thread From: Krzysztof Kozlowski @ 2021-09-01 12:31 UTC (permalink / raw) To: Jackie Liu, Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel On 01/09/2021 14:28, Jackie Liu wrote: > > Hi Krzysztof, Thanks for you message. > > 在 2021/9/1 下午8:09, Krzysztof Kozlowski 写道: >> On 31/08/2021 11:57, Jackie Liu wrote: >>> From: Jackie Liu <liuyun01@kylinos.cn> >>> >>> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. >>> let's add an error pointer check in s3c24xx_handle_irq. >>> >>> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") >>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> >> >> Please use scripts/get_maintainers.pl to get list of mailing lists to >> CC. You skipped two - arm and LKML. >> >>> --- >>> arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c >>> index 0c631c14a817..d58bf0f9bf9a 100644 >>> --- a/arch/arm/mach-s3c/irq-s3c24xx.c >>> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c >>> @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, >>> static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) >>> { >>> do { >>> - if (likely(s3c_intc[0])) >>> + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) >>> if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) >> >> Thanks for the patch but it does not look entirely correct. >> >> For platform based machines, neither ERR nor NULL can happen here. >> The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: >> s3c_intc[0] = s3c24xx_init_intc() >> >> If this fails, the next calls to s3c24xx_init_intc() won't be executed. >> >> For DT machine, s3c_init_intc_of() could set the IRQ handler without >> setting s3c_intc[0] only if it was called with num_ctrl=0. There is no >> such code path, so again the s3c_intc[0] will have a valid pointer if >> set_handle_irq() is called. >> >> Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. >> >> The code can be simplified by removing if(), if we really wanted and >> were sure about it. > > In fact, I didn't study his underlying logic in depth, but found that > this place was not particularly perfect based on the return value of the > function, because I happened to encounter a similar problem elsewhere. > >> >> >>> continue; >>> >>> - if (s3c_intc[2]) >>> + if (!IS_ERR_OR_NULL(s3c_intc[2])) >> >> For the non-DT case, this seems ugly but proper solution. The >> s3c_intc[2] could be NULL (not set at all) or set as ERR (if >> s3c24xx_init_intc() fails). >> >>> if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) >>> continue; >>> >>> >> >> >> Best regards, >> Krzysztof >> > > Would you mind review v2? Sure, please send it. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() @ 2021-09-01 12:31 ` Krzysztof Kozlowski 0 siblings, 0 replies; 6+ messages in thread From: Krzysztof Kozlowski @ 2021-09-01 12:31 UTC (permalink / raw) To: Jackie Liu, Jackie Liu; +Cc: linux-samsung-soc, linux-arm-kernel On 01/09/2021 14:28, Jackie Liu wrote: > > Hi Krzysztof, Thanks for you message. > > 在 2021/9/1 下午8:09, Krzysztof Kozlowski 写道: >> On 31/08/2021 11:57, Jackie Liu wrote: >>> From: Jackie Liu <liuyun01@kylinos.cn> >>> >>> The s3c24xx_init_intc() returns an error pointer upon failure, not NULL. >>> let's add an error pointer check in s3c24xx_handle_irq. >>> >>> Fixes: 1f629b7a3ced ("ARM: S3C24XX: transform irq handling into a declarative form") >>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn> >> >> Please use scripts/get_maintainers.pl to get list of mailing lists to >> CC. You skipped two - arm and LKML. >> >>> --- >>> arch/arm/mach-s3c/irq-s3c24xx.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/arch/arm/mach-s3c/irq-s3c24xx.c b/arch/arm/mach-s3c/irq-s3c24xx.c >>> index 0c631c14a817..d58bf0f9bf9a 100644 >>> --- a/arch/arm/mach-s3c/irq-s3c24xx.c >>> +++ b/arch/arm/mach-s3c/irq-s3c24xx.c >>> @@ -362,11 +362,11 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc, >>> static asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs) >>> { >>> do { >>> - if (likely(s3c_intc[0])) >>> + if (likely(!IS_ERR_OR_NULL(s3c_intc[0]))) >>> if (s3c24xx_handle_intc(s3c_intc[0], regs, 0)) >> >> Thanks for the patch but it does not look entirely correct. >> >> For platform based machines, neither ERR nor NULL can happen here. >> The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds: >> s3c_intc[0] = s3c24xx_init_intc() >> >> If this fails, the next calls to s3c24xx_init_intc() won't be executed. >> >> For DT machine, s3c_init_intc_of() could set the IRQ handler without >> setting s3c_intc[0] only if it was called with num_ctrl=0. There is no >> such code path, so again the s3c_intc[0] will have a valid pointer if >> set_handle_irq() is called. >> >> Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something. >> >> The code can be simplified by removing if(), if we really wanted and >> were sure about it. > > In fact, I didn't study his underlying logic in depth, but found that > this place was not particularly perfect based on the return value of the > function, because I happened to encounter a similar problem elsewhere. > >> >> >>> continue; >>> >>> - if (s3c_intc[2]) >>> + if (!IS_ERR_OR_NULL(s3c_intc[2])) >> >> For the non-DT case, this seems ugly but proper solution. The >> s3c_intc[2] could be NULL (not set at all) or set as ERR (if >> s3c24xx_init_intc() fails). >> >>> if (s3c24xx_handle_intc(s3c_intc[2], regs, 64)) >>> continue; >>> >>> >> >> >> Best regards, >> Krzysztof >> > > Would you mind review v2? Sure, please send it. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-01 12:39 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-31 9:57 [PATCH] ARM: s3c: irq-s3c24xx: Fix return value check for s3c24xx_init_intc() Jackie Liu 2021-09-01 12:09 ` Krzysztof Kozlowski 2021-09-01 12:28 ` Jackie Liu 2021-09-01 12:28 ` Jackie Liu 2021-09-01 12:31 ` Krzysztof Kozlowski 2021-09-01 12:31 ` Krzysztof Kozlowski
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.