* [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
@ 2025-12-02 18:15 Thorsten Blum
2025-12-02 18:28 ` Helge Deller
0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Blum @ 2025-12-02 18:15 UTC (permalink / raw)
To: Helge Deller, Chelsy Ratnawat, Thomas Zimmermann, Andy Shevchenko,
Raag Jadav
Cc: Thorsten Blum, stable, linux-fbdev, dri-devel, linux-kernel
The variables were never clamped because the return value of clamp_val()
was not used. Fix this by assigning the clamped values, and use clamp()
instead of clamp_val().
Cc: stable@vger.kernel.org
Fixes: 3f16ff608a75 ("[ARM] pxafb: cleanup of the timing checking code")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/video/fbdev/pxafb.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index b96a8a96bce8..e418eee825fb 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -419,12 +419,12 @@ static int pxafb_adjust_timing(struct pxafb_info *fbi,
var->yres = max_t(int, var->yres, MIN_YRES);
if (!(fbi->lccr0 & LCCR0_LCDT)) {
- clamp_val(var->hsync_len, 1, 64);
- clamp_val(var->vsync_len, 1, 64);
- clamp_val(var->left_margin, 1, 255);
- clamp_val(var->right_margin, 1, 255);
- clamp_val(var->upper_margin, 1, 255);
- clamp_val(var->lower_margin, 1, 255);
+ var->hsync_len = clamp(var->hsync_len, 1, 64);
+ var->vsync_len = clamp(var->vsync_len, 1, 64);
+ var->left_margin = clamp(var->left_margin, 1, 255);
+ var->right_margin = clamp(var->right_margin, 1, 255);
+ var->upper_margin = clamp(var->upper_margin, 1, 255);
+ var->lower_margin = clamp(var->lower_margin, 1, 255);
}
/* make sure each line is aligned on word boundary */
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-02 18:15 [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing Thorsten Blum
@ 2025-12-02 18:28 ` Helge Deller
2025-12-02 18:36 ` Thorsten Blum
0 siblings, 1 reply; 7+ messages in thread
From: Helge Deller @ 2025-12-02 18:28 UTC (permalink / raw)
To: Thorsten Blum, Chelsy Ratnawat, Thomas Zimmermann,
Andy Shevchenko, Raag Jadav
Cc: linux-fbdev, dri-devel, linux-kernel
On 12/2/25 19:15, Thorsten Blum wrote:
> The variables were never clamped because the return value of clamp_val()
> was not used. Fix this by assigning the clamped values, and use clamp()
> instead of clamp_val().
>
> Cc: stable@vger.kernel.org
> Fixes: 3f16ff608a75 ("[ARM] pxafb: cleanup of the timing checking code")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/video/fbdev/pxafb.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Thanks for the patch!
It looks good, so I'll include it in the fbdev tree.
Out of curiosity:
How did you notice? Do you actually have the hardware and tested it?
Helge
> diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
> index b96a8a96bce8..e418eee825fb 100644
> --- a/drivers/video/fbdev/pxafb.c
> +++ b/drivers/video/fbdev/pxafb.c
> @@ -419,12 +419,12 @@ static int pxafb_adjust_timing(struct pxafb_info *fbi,
> var->yres = max_t(int, var->yres, MIN_YRES);
>
> if (!(fbi->lccr0 & LCCR0_LCDT)) {
> - clamp_val(var->hsync_len, 1, 64);
> - clamp_val(var->vsync_len, 1, 64);
> - clamp_val(var->left_margin, 1, 255);
> - clamp_val(var->right_margin, 1, 255);
> - clamp_val(var->upper_margin, 1, 255);
> - clamp_val(var->lower_margin, 1, 255);
> + var->hsync_len = clamp(var->hsync_len, 1, 64);
> + var->vsync_len = clamp(var->vsync_len, 1, 64);
> + var->left_margin = clamp(var->left_margin, 1, 255);
> + var->right_margin = clamp(var->right_margin, 1, 255);
> + var->upper_margin = clamp(var->upper_margin, 1, 255);
> + var->lower_margin = clamp(var->lower_margin, 1, 255);
> }
>
> /* make sure each line is aligned on word boundary */
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-02 18:28 ` Helge Deller
@ 2025-12-02 18:36 ` Thorsten Blum
2025-12-02 19:36 ` Helge Deller
2025-12-02 20:32 ` David Laight
0 siblings, 2 replies; 7+ messages in thread
From: Thorsten Blum @ 2025-12-02 18:36 UTC (permalink / raw)
To: Helge Deller
Cc: Chelsy Ratnawat, Thomas Zimmermann, Andy Shevchenko, Raag Jadav,
linux-fbdev, dri-devel, linux-kernel
On 2. Dec 2025, at 19:28, Helge Deller wrote:
> On 12/2/25 19:15, Thorsten Blum wrote:
>> The variables were never clamped because the return value of clamp_val()
>> was not used. Fix this by assigning the clamped values, and use clamp()
>> instead of clamp_val().
>> Cc: stable@vger.kernel.org
>> Fixes: 3f16ff608a75 ("[ARM] pxafb: cleanup of the timing checking code")
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> drivers/video/fbdev/pxafb.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> Thanks for the patch!
> It looks good, so I'll include it in the fbdev tree.
> Out of curiosity:
> How did you notice? Do you actually have the hardware and tested it?
I only compile-tested it.
I stumbled upon another driver with the same bug and then used grep to
search for other instances and found about 6 or 7, including this one.
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-02 18:36 ` Thorsten Blum
@ 2025-12-02 19:36 ` Helge Deller
2025-12-03 9:49 ` Andy Shevchenko
2025-12-02 20:32 ` David Laight
1 sibling, 1 reply; 7+ messages in thread
From: Helge Deller @ 2025-12-02 19:36 UTC (permalink / raw)
To: Thorsten Blum
Cc: Chelsy Ratnawat, Thomas Zimmermann, Andy Shevchenko, Raag Jadav,
linux-fbdev, dri-devel, linux-kernel
On 12/2/25 19:36, Thorsten Blum wrote:
> On 2. Dec 2025, at 19:28, Helge Deller wrote:
>> On 12/2/25 19:15, Thorsten Blum wrote:
>>> The variables were never clamped because the return value of clamp_val()
>>> was not used. Fix this by assigning the clamped values, and use clamp()
>>> instead of clamp_val().
>>> Cc: stable@vger.kernel.org
>>> Fixes: 3f16ff608a75 ("[ARM] pxafb: cleanup of the timing checking code")
>>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>>> ---
>>> drivers/video/fbdev/pxafb.c | 12 ++++++------
>>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> Thanks for the patch!
>> It looks good, so I'll include it in the fbdev tree.
>> Out of curiosity:
>> How did you notice? Do you actually have the hardware and tested it?
>
> I only compile-tested it.
>
> I stumbled upon another driver with the same bug and then used grep to
> search for other instances and found about 6 or 7, including this one.
Ok. But this then means, maybe the clamping isn't needed (since nobody complained),
or that nobody noticed because nobody uses the driver any longer.
Anyway, I believe the patch is correct, so I leave it in.
Thank you!
Helge
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-02 18:36 ` Thorsten Blum
2025-12-02 19:36 ` Helge Deller
@ 2025-12-02 20:32 ` David Laight
1 sibling, 0 replies; 7+ messages in thread
From: David Laight @ 2025-12-02 20:32 UTC (permalink / raw)
To: Thorsten Blum
Cc: Helge Deller, Chelsy Ratnawat, Thomas Zimmermann, Andy Shevchenko,
Raag Jadav, linux-fbdev, dri-devel, linux-kernel
On Tue, 2 Dec 2025 19:36:17 +0100
Thorsten Blum <thorsten.blum@linux.dev> wrote:
> On 2. Dec 2025, at 19:28, Helge Deller wrote:
> > On 12/2/25 19:15, Thorsten Blum wrote:
> >> The variables were never clamped because the return value of clamp_val()
> >> was not used. Fix this by assigning the clamped values, and use clamp()
> >> instead of clamp_val().
> >> Cc: stable@vger.kernel.org
> >> Fixes: 3f16ff608a75 ("[ARM] pxafb: cleanup of the timing checking code")
> >> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> >> ---
> >> drivers/video/fbdev/pxafb.c | 12 ++++++------
> >> 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > Thanks for the patch!
> > It looks good, so I'll include it in the fbdev tree.
> > Out of curiosity:
> > How did you notice? Do you actually have the hardware and tested it?
>
> I only compile-tested it.
>
> I stumbled upon another driver with the same bug and then used grep to
> search for other instances and found about 6 or 7, including this one.
I've just hacked minmax.h so clamp() and clamp_t() (and thus clamp_val())
are 'static inline u64 __must_check clamp(...)'.
Didn't find any in any other files.
But I think you missed some double error in the same file (nearby).
David
>
> Thanks,
> Thorsten
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-02 19:36 ` Helge Deller
@ 2025-12-03 9:49 ` Andy Shevchenko
2025-12-03 10:30 ` Raag Jadav
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2025-12-03 9:49 UTC (permalink / raw)
To: Helge Deller
Cc: Thorsten Blum, Chelsy Ratnawat, Thomas Zimmermann, Raag Jadav,
linux-fbdev, dri-devel, linux-kernel
On Tue, Dec 02, 2025 at 08:36:08PM +0100, Helge Deller wrote:
> On 12/2/25 19:36, Thorsten Blum wrote:
> > On 2. Dec 2025, at 19:28, Helge Deller wrote:
> > > On 12/2/25 19:15, Thorsten Blum wrote:
...
> > > How did you notice? Do you actually have the hardware and tested it?
> >
> > I only compile-tested it.
> >
> > I stumbled upon another driver with the same bug and then used grep to
> > search for other instances and found about 6 or 7, including this one.
>
> Ok. But this then means, maybe the clamping isn't needed (since nobody complained),
> or that nobody noticed because nobody uses the driver any longer.
I think it's a combination of factors: 1) rarely people have this hardware,
especially nowadays, to run more or less new kernel; 2) there are no conditions
happened that this patch fixes in their environments; 3) something else I
missed.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing
2025-12-03 9:49 ` Andy Shevchenko
@ 2025-12-03 10:30 ` Raag Jadav
0 siblings, 0 replies; 7+ messages in thread
From: Raag Jadav @ 2025-12-03 10:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Helge Deller, Thorsten Blum, Chelsy Ratnawat, Thomas Zimmermann,
linux-fbdev, dri-devel, linux-kernel
On Wed, Dec 03, 2025 at 11:49:07AM +0200, Andy Shevchenko wrote:
> On Tue, Dec 02, 2025 at 08:36:08PM +0100, Helge Deller wrote:
> > On 12/2/25 19:36, Thorsten Blum wrote:
> > > On 2. Dec 2025, at 19:28, Helge Deller wrote:
> > > > On 12/2/25 19:15, Thorsten Blum wrote:
>
> ...
>
> > > > How did you notice? Do you actually have the hardware and tested it?
> > >
> > > I only compile-tested it.
> > >
> > > I stumbled upon another driver with the same bug and then used grep to
> > > search for other instances and found about 6 or 7, including this one.
> >
> > Ok. But this then means, maybe the clamping isn't needed (since nobody complained),
> > or that nobody noticed because nobody uses the driver any longer.
>
> I think it's a combination of factors: 1) rarely people have this hardware,
> especially nowadays, to run more or less new kernel; 2) there are no conditions
> happened that this patch fixes in their environments; 3) something else I
> missed.
I had a quick look at commit 3f16ff608a75 and seems like there wasn't much
happening either way.
Raag
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-03 10:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 18:15 [PATCH] fbdev/pxafb: Fix multiple clamped values in pxafb_adjust_timing Thorsten Blum
2025-12-02 18:28 ` Helge Deller
2025-12-02 18:36 ` Thorsten Blum
2025-12-02 19:36 ` Helge Deller
2025-12-03 9:49 ` Andy Shevchenko
2025-12-03 10:30 ` Raag Jadav
2025-12-02 20:32 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).