* [PATCH 00/38] Fixes related to incorrect usage of unsigned types
@ 2015-09-21 13:33 Andrzej Hajda
2015-09-21 13:33 ` [PATCH 14/38] clk: vt8500: fix sign of possible PLL values Andrzej Hajda
2015-09-21 13:42 ` [PATCH 00/38] Fixes related to incorrect usage of unsigned types David Howells
0 siblings, 2 replies; 10+ messages in thread
From: Andrzej Hajda @ 2015-09-21 13:33 UTC (permalink / raw)
To: linux-kernel
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Alan Stern, Alessandro Zummo, Alexander Kuleshov,
Alexandre Belloni, Alex Deucher, Alison Wang, Amitkumar Karwar,
Andreas Dilger, Andrew Morton, Arend van Spriel, Arnd Bergmann,
Boris BREZILLON, brcm80211-dev-list, Brett Rudley,
Christian König, Daniel Vetter, David Airlie, David Howells,
David S. Miller, devel, dev, Dmitry Torokhov, Doug Ledford,
dri-devel, Eric Paris, Franky (Zhenhui) Lin, Giuseppe Cavallaro,
Greg Kroah-Hartman, Hal Rosenstock, Hans Verkuil, Hante Meuleman,
Herbert Xu, intel-gfx, Ivan Mikhaylov, Jacek Anaszewski,
Jani Nikula, Jean-Christophe Plagniol-Villard, Jianwei Wang,
Jiri Slaby, John Stultz, Jussi Kivilinna, Kalle Valo,
Karsten Keil, linux-api, linux-arm-kernel, linux-cachefs,
linux-clk, linux-crypto, linux-fbdev, linux-input, linux-leds,
linux-media, linux-mips, linux-mm, linux-omap, linux-rdma,
linux-serial, linux-sh, linux-usb, linux-wireless, lustre-devel,
Magnus Damm, Markos Chandras, Mark Rutland, Matt Mackall,
Mauro Carvalho Chehab, Michael Turquette, netdev, Nick Dyer,
Nishant Sarmukadam, Oleg Drokin, Olof Johansson, Pawel Moll,
Philipp Zabel, Pravin Shelar, Punit Agrawal, Ralf Baechle,
Richard Purdie, rtc-linux, Sakari Ailus, Sean Hefty,
Sebastian Reichel, Shuah Khan, Simon Horman, Stephen Boyd,
Steve Glendinning, Suzuki K. Poulose, Tapasweni Pathak,
Thomas Gleixner, Tomi Valkeinen, Tony Luck, Wei Yang, Will Deacon,
Woojung.Huh@microchip.com, yalin wang
Hi,
This is set of independent patches. The only connection between
them is that they try to address problems spotted by proposed
coccinelle semantic patch unsigned_lesser_than_zero.cocci[1].
Semantic patch finds comparisons of types:
unsigned < 0
unsigned >= 0
The former is always false, the latter is always true.
Such comparisons are useless, so theoretically they could be
safely removed, but their presence quite often indicates bugs.
This patchset contains mainly real bug fixes(patches 01-25),
usually type fixes.
Patches 26-37 removes unnecessary checks. Semantic patch found
much more such places (more than 80), but since every case needs
some analysis I have decided to leave them for antoher patchset.
The last patch should be probably replaced with something better,
I guess it should be treated rather as bug report.
The patches are based on linux-next (20150918).
Patches were only compile tested, so please look at them carefully.
I have sent all patches to linux-kernel mailing list. Individual
patches + cover letter went also to apropriate addresses,
according to get_maintainers.pl script.
One more thing. To fullfill different maintaner/subsystem requirements
I have decided to prefix patch subjects with prefixes present in
last 10 commits for affected files. I am not sure if this is the
best solution, if there are any better solutions please let me know :)
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Regards
Andrzej
Andrzej Hajda (38):
arm-cci: fix handling cpumask_any_but return value
bus: arm-ccn: fix handling cpumask_any_but return value
drm/i915: fix handling gen8_emit_flush_coherentl3_wa result
IB/ehca: fix handling idr_alloc result
staging: lustre: fix handling lustre_posix_acl_xattr_filter result
tty: serial: lpc32xx_hs: fix handling platform_get_irq result
usb: host: ehci-msm: fix handling platform_get_irq result
openvswitch: fix handling result of ipv6_skip_exthdr
selftests/timers: fix write return value handlng
hwrng: fix handling platform_get_irq
HSI: omap_ssi: fix handling ida_simple_get result
HSI: omap_ssi_port: fix handling of_get_named_gpio result
ARM: shmobile: apmu: correct type of CPU id
clk: vt8500: fix sign of possible PLL values
drm/layerscape: fix handling fsl_dcu_drm_plane_index result
gpu: ipu-v3: fix div_ratio type
isdn: hisax: fix frame calculation
net/ibm/emac: fix type of phy_mode
net: stmmac: fix type of entry variable
net: brcm80211: fix range check
mwifiex: fix comparison expression
orinoco: fix checking for default value
rndis_wlan: fix checking for default value
rtc: opal: fix type of token
staging: media: davinci_vpfe: fix ipipe_mode type
staging: lustre: remove invalid check
usbnet: remove invalid check
video/omap: remove invalid check
Input: touchscreen: atmel: remove invalid check
leds: flash: remove invalid check
leds: tca6507: remove invalid check
fs/cachefiles: remove invalid checks
mm/memblock.c: remove invalid check
perf: remove invalid check
ptrace: remove invalid check
MIPS: remove invalid check
zlib_deflate/deftree: change always true condition to 1
drm/radeon: simplify boot level calculation
arch/arm/mach-shmobile/platsmp-apmu.c | 2 +-
arch/mips/mm/sc-mips.c | 4 ++--
arch/sh/kernel/ptrace_32.c | 3 +--
arch/sh/kernel/ptrace_64.c | 4 ++--
drivers/bus/arm-cci.c | 2 +-
drivers/bus/arm-ccn.c | 2 +-
drivers/char/hw_random/xgene-rng.c | 7 ++++---
drivers/clk/clk-vt8500.c | 6 +++---
drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 11 +----------
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 3 ++-
drivers/gpu/drm/i915/intel_lrc.c | 7 ++++---
drivers/gpu/drm/radeon/kv_dpm.c | 11 +----------
drivers/gpu/ipu-v3/ipu-csi.c | 2 +-
drivers/hsi/controllers/omap_ssi.c | 7 +++----
drivers/hsi/controllers/omap_ssi_port.c | 8 ++++----
drivers/input/touchscreen/atmel_mxt_ts.c | 2 +-
drivers/isdn/hisax/hfc4s8s_l1.c | 10 +++++-----
drivers/leds/led-class-flash.c | 2 +-
drivers/leds/leds-tca6507.c | 2 +-
drivers/net/ethernet/ibm/emac/core.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
drivers/net/usb/lan78xx.c | 5 -----
drivers/net/usb/smsc75xx.c | 5 -----
drivers/net/usb/smsc95xx.c | 5 -----
drivers/net/wireless/brcm80211/brcmsmac/main.c | 2 +-
drivers/net/wireless/mwifiex/11n_rxreorder.c | 4 ++--
drivers/net/wireless/orinoco/cfg.c | 6 +++---
drivers/net/wireless/rndis_wlan.c | 2 +-
drivers/rtc/rtc-opal.c | 4 ++--
drivers/staging/lustre/lustre/llite/xattr.c | 7 ++++---
drivers/staging/lustre/lustre/osc/lproc_osc.c | 3 ---
drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c | 2 +-
drivers/staging/rdma/ehca/ehca_cq.c | 13 +++++++------
drivers/tty/serial/lpc32xx_hs.c | 7 ++++---
drivers/usb/host/ehci-msm.c | 6 +++---
drivers/video/fbdev/omap/omapfb_main.c | 5 -----
fs/cachefiles/bind.c | 9 +++------
fs/cachefiles/daemon.c | 6 +++---
lib/zlib_deflate/deftree.c | 2 +-
mm/memblock.c | 2 +-
net/openvswitch/conntrack.c | 2 +-
tools/testing/selftests/timers/clocksource-switch.c | 2 +-
42 files changed, 79 insertions(+), 119 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 14/38] clk: vt8500: fix sign of possible PLL values
2015-09-21 13:33 [PATCH 00/38] Fixes related to incorrect usage of unsigned types Andrzej Hajda
@ 2015-09-21 13:33 ` Andrzej Hajda
2015-10-01 22:56 ` Stephen Boyd
2015-09-21 13:42 ` [PATCH 00/38] Fixes related to incorrect usage of unsigned types David Howells
1 sibling, 1 reply; 10+ messages in thread
From: Andrzej Hajda @ 2015-09-21 13:33 UTC (permalink / raw)
To: linux-kernel
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Michael Turquette, Stephen Boyd, linux-clk
With unsigned values underflow in loops can occur resulting in
theoretically infinite loops.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
drivers/clk/clk-vt8500.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 37e9288..098e9fa 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -384,7 +384,7 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ int mul, div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
@@ -452,7 +452,7 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *filter, u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ int mul, div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
@@ -496,7 +496,7 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ int mul, div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
2015-09-21 13:33 [PATCH 00/38] Fixes related to incorrect usage of unsigned types Andrzej Hajda
2015-09-21 13:33 ` [PATCH 14/38] clk: vt8500: fix sign of possible PLL values Andrzej Hajda
@ 2015-09-21 13:42 ` David Howells
2015-09-22 9:13 ` Andrzej Hajda
1 sibling, 1 reply; 10+ messages in thread
From: David Howells @ 2015-09-21 13:42 UTC (permalink / raw)
To: Andrzej Hajda
Cc: dhowells, linux-kernel, linux-api, linux-arm-kernel,
linux-cachefs, linux-clk, linux-crypto, linux-fbdev, linux-input,
linux-leds, linux-media, linux-mips, linux-mm, linux-omap,
linux-rdma, linux-serial, linux-sh, linux-usb, linux-wireless,
lustre-devel
Andrzej Hajda <a.hajda@samsung.com> wrote:
> Semantic patch finds comparisons of types:
> unsigned < 0
> unsigned >= 0
> The former is always false, the latter is always true.
> Such comparisons are useless, so theoretically they could be
> safely removed, but their presence quite often indicates bugs.
Or someone has left them in because they don't matter and there's the
possibility that the type being tested might be or become signed under some
circumstances. If the comparison is useless, I'd expect the compiler to just
discard it - for such cases your patch is pointless.
If I have, for example:
unsigned x;
if (x == 0 || x > 27)
give_a_range_error();
I will write this as:
unsigned x;
if (x <= 0 || x > 27)
give_a_range_error();
because it that gives a way to handle x being changed to signed at some point
in the future for no cost. In which case, your changing the <= to an ==
"because the < part of the case is useless" is arguably wrong.
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
2015-09-21 13:42 ` [PATCH 00/38] Fixes related to incorrect usage of unsigned types David Howells
@ 2015-09-22 9:13 ` Andrzej Hajda
2015-09-22 9:46 ` Jacek Anaszewski
0 siblings, 1 reply; 10+ messages in thread
From: Andrzej Hajda @ 2015-09-22 9:13 UTC (permalink / raw)
To: David Howells
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
linux-kernel, brcm80211-dev-list, devel, dev, dri-devel,
intel-gfx, linux-api, linux-arm-kernel, linux-cachefs, linux-clk,
linux-crypto, linux-fbdev, linux-input, linux-kernel, linux-leds,
linux-media, linux-mips, linux-mm, linux-omap, linux-rdma,
linux-serial, linux-sh, linux-usb, linux-wireless, lustre-devel,
netdev, rtc-linux
On 09/21/2015 03:42 PM, David Howells wrote:
> Andrzej Hajda <a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> wrote:
>
>> Semantic patch finds comparisons of types:
>> unsigned < 0
>> unsigned >= 0
>> The former is always false, the latter is always true.
>> Such comparisons are useless, so theoretically they could be
>> safely removed, but their presence quite often indicates bugs.
>
> Or someone has left them in because they don't matter and there's the
> possibility that the type being tested might be or become signed under some
> circumstances. If the comparison is useless, I'd expect the compiler to just
> discard it - for such cases your patch is pointless.
>
> If I have, for example:
>
> unsigned x;
>
> if (x == 0 || x > 27)
> give_a_range_error();
>
> I will write this as:
>
> unsigned x;
>
> if (x <= 0 || x > 27)
> give_a_range_error();
>
> because it that gives a way to handle x being changed to signed at some point
> in the future for no cost. In which case, your changing the <= to an ==
> "because the < part of the case is useless" is arguably wrong.
This is why I have not checked for such cases - I have skipped checks of type
unsigned <= 0
exactly for the reasons above.
However I have left two other checks as they seems to me more suspicious - they
are always true or false. But as Dmitry and Andrew pointed out Linus have quite
strong opinion against removing range checks in such cases as he finds it
clearer. I think it applies to patches 29-36. I am not sure about patches 26-28,37.
Regards
Andrzej
>
> David
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
2015-09-22 9:13 ` Andrzej Hajda
@ 2015-09-22 9:46 ` Jacek Anaszewski
0 siblings, 0 replies; 10+ messages in thread
From: Jacek Anaszewski @ 2015-09-22 9:46 UTC (permalink / raw)
To: Andrzej Hajda
Cc: David Howells, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
linux-kernel, brcm80211-dev-list, devel, dev, dri-devel,
intel-gfx, linux-api, linux-arm-kernel, linux-cachefs, linux-clk,
linux-crypto, linux-fbdev, linux-input, linux-leds, linux-media,
linux-mips, linux-mm, linux-omap, linux-rdma, linux-serial,
linux-sh, linux-usb, linux-wireless, lustre-devel, netdev,
rtc-linux
On 09/22/2015 11:13 AM, Andrzej Hajda wrote:
> On 09/21/2015 03:42 PM, David Howells wrote:
>> Andrzej Hajda <a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> wrote:
>>
>>> Semantic patch finds comparisons of types:
>>> unsigned < 0
>>> unsigned >= 0
>>> The former is always false, the latter is always true.
>>> Such comparisons are useless, so theoretically they could be
>>> safely removed, but their presence quite often indicates bugs.
>>
>> Or someone has left them in because they don't matter and there's the
>> possibility that the type being tested might be or become signed under some
>> circumstances. If the comparison is useless, I'd expect the compiler to just
>> discard it - for such cases your patch is pointless.
>>
>> If I have, for example:
>>
>> unsigned x;
>>
>> if (x == 0 || x > 27)
>> give_a_range_error();
>>
>> I will write this as:
>>
>> unsigned x;
>>
>> if (x <= 0 || x > 27)
>> give_a_range_error();
>>
>> because it that gives a way to handle x being changed to signed at some point
>> in the future for no cost. In which case, your changing the <= to an ==
>> "because the < part of the case is useless" is arguably wrong.
>
> This is why I have not checked for such cases - I have skipped checks of type
> unsigned <= 0
> exactly for the reasons above.
>
> However I have left two other checks as they seems to me more suspicious - they
> are always true or false. But as Dmitry and Andrew pointed out Linus have quite
> strong opinion against removing range checks in such cases as he finds it
> clearer. I think it applies to patches 29-36. I am not sure about patches 26-28,37.
Dropped 30/38 and 31/38 from LED tree then.
--
Best Regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 14/38] clk: vt8500: fix sign of possible PLL values
2015-09-21 13:33 ` [PATCH 14/38] clk: vt8500: fix sign of possible PLL values Andrzej Hajda
@ 2015-10-01 22:56 ` Stephen Boyd
2015-10-02 4:49 ` [PATCH v2 " Andrzej Hajda
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Boyd @ 2015-10-01 22:56 UTC (permalink / raw)
To: Andrzej Hajda
Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Michael Turquette, linux-clk
On 09/21, Andrzej Hajda wrote:
> With unsigned values underflow in loops can occur resulting in
> theoretically infinite loops.
>
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> drivers/clk/clk-vt8500.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
> index 37e9288..098e9fa 100644
> --- a/drivers/clk/clk-vt8500.c
> +++ b/drivers/clk/clk-vt8500.c
> @@ -384,7 +384,7 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + int mul, div1, div2;
Only div2 seems to need the treatment here.
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -452,7 +452,7 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
> static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *filter, u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + int mul, div1, div2;
And here div1 and div2 are the only ones.
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -496,7 +496,7 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + int mul, div1, div2;
And div1 and div2 here.
Can we focus the changes on the actual problematic variables? I
suppose this has never mattered because we break out of these
loops.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 14/38] clk: vt8500: fix sign of possible PLL values
2015-10-01 22:56 ` Stephen Boyd
@ 2015-10-02 4:49 ` Andrzej Hajda
2015-12-14 10:30 ` Andrzej Hajda
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Andrzej Hajda @ 2015-10-02 4:49 UTC (permalink / raw)
To: Stephen Boyd
Cc: Andrzej Hajda, linux-kernel, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Michael Turquette, linux-clk
With unsigned values underflow in loops can occur resulting in
theoretically infinite loops.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
Hi Stephen,
This is modified version according to your request, ie only problematic
variables have changed type.
I still think that 1st version is better, but of course it is up to you.
Regards
Andrzej
drivers/clk/clk-vt8500.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
index 37e9288..98c4492 100644
--- a/drivers/clk/clk-vt8500.c
+++ b/drivers/clk/clk-vt8500.c
@@ -384,7 +384,8 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ u32 mul, div1;
+ int div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
@@ -452,7 +453,8 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *filter, u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ u32 mul;
+ int div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
@@ -496,7 +498,8 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
u32 *multiplier, u32 *divisor1, u32 *divisor2)
{
- u32 mul, div1, div2;
+ u32 mul;
+ int div1, div2;
u32 best_mul, best_div1, best_div2;
unsigned long tclk, rate_err, best_err;
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 14/38] clk: vt8500: fix sign of possible PLL values
2015-10-02 4:49 ` [PATCH v2 " Andrzej Hajda
@ 2015-12-14 10:30 ` Andrzej Hajda
2016-01-05 14:24 ` Andrzej Hajda
2016-01-30 0:44 ` Stephen Boyd
2 siblings, 0 replies; 10+ messages in thread
From: Andrzej Hajda @ 2015-12-14 10:30 UTC (permalink / raw)
To: Stephen Boyd
Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Michael Turquette, linux-clk
Hi,
Ping.
Regards
Andrzej
On 10/02/2015 06:49 AM, Andrzej Hajda wrote:
> With unsigned values underflow in loops can occur resulting in
> theoretically infinite loops.
>
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> Hi Stephen,
>
> This is modified version according to your request, ie only problematic
> variables have changed type.
> I still think that 1st version is better, but of course it is up to you.
>
> Regards
> Andrzej
>
> drivers/clk/clk-vt8500.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
> index 37e9288..98c4492 100644
> --- a/drivers/clk/clk-vt8500.c
> +++ b/drivers/clk/clk-vt8500.c
> @@ -384,7 +384,8 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul, div1;
> + int div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -452,7 +453,8 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
> static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *filter, u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul;
> + int div1, div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -496,7 +498,8 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul;
> + int div1, div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 14/38] clk: vt8500: fix sign of possible PLL values
2015-10-02 4:49 ` [PATCH v2 " Andrzej Hajda
2015-12-14 10:30 ` Andrzej Hajda
@ 2016-01-05 14:24 ` Andrzej Hajda
2016-01-30 0:44 ` Stephen Boyd
2 siblings, 0 replies; 10+ messages in thread
From: Andrzej Hajda @ 2016-01-05 14:24 UTC (permalink / raw)
To: Stephen Boyd
Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Michael Turquette, linux-clk
Ping
Regards
Andrzej
On 10/02/2015 06:49 AM, Andrzej Hajda wrote:
> With unsigned values underflow in loops can occur resulting in
> theoretically infinite loops.
>
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> Hi Stephen,
>
> This is modified version according to your request, ie only problematic
> variables have changed type.
> I still think that 1st version is better, but of course it is up to you.
>
> Regards
> Andrzej
>
> drivers/clk/clk-vt8500.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
> index 37e9288..98c4492 100644
> --- a/drivers/clk/clk-vt8500.c
> +++ b/drivers/clk/clk-vt8500.c
> @@ -384,7 +384,8 @@ static void vt8500_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8650_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul, div1;
> + int div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -452,7 +453,8 @@ static u32 wm8750_get_filter(u32 parent_rate, u32 divisor1)
> static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *filter, u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul;
> + int div1, div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
> @@ -496,7 +498,8 @@ static void wm8750_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> static void wm8850_find_pll_bits(unsigned long rate, unsigned long parent_rate,
> u32 *multiplier, u32 *divisor1, u32 *divisor2)
> {
> - u32 mul, div1, div2;
> + u32 mul;
> + int div1, div2;
> u32 best_mul, best_div1, best_div2;
> unsigned long tclk, rate_err, best_err;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 14/38] clk: vt8500: fix sign of possible PLL values
2015-10-02 4:49 ` [PATCH v2 " Andrzej Hajda
2015-12-14 10:30 ` Andrzej Hajda
2016-01-05 14:24 ` Andrzej Hajda
@ 2016-01-30 0:44 ` Stephen Boyd
2 siblings, 0 replies; 10+ messages in thread
From: Stephen Boyd @ 2016-01-30 0:44 UTC (permalink / raw)
To: Andrzej Hajda
Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Michael Turquette, linux-clk
On 10/02, Andrzej Hajda wrote:
> With unsigned values underflow in loops can occur resulting in
> theoretically infinite loops.
>
> The problem has been detected using proposed semantic patch
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-01-30 0:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-21 13:33 [PATCH 00/38] Fixes related to incorrect usage of unsigned types Andrzej Hajda
2015-09-21 13:33 ` [PATCH 14/38] clk: vt8500: fix sign of possible PLL values Andrzej Hajda
2015-10-01 22:56 ` Stephen Boyd
2015-10-02 4:49 ` [PATCH v2 " Andrzej Hajda
2015-12-14 10:30 ` Andrzej Hajda
2016-01-05 14:24 ` Andrzej Hajda
2016-01-30 0:44 ` Stephen Boyd
2015-09-21 13:42 ` [PATCH 00/38] Fixes related to incorrect usage of unsigned types David Howells
2015-09-22 9:13 ` Andrzej Hajda
2015-09-22 9:46 ` Jacek Anaszewski
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).