* [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Sudeep Holla
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Rafael J. Wysocki, Viresh Kumar,
open list:SYSTEM CONTROL & POWER INTERFACE SCPI Message...,
open list:CPU FREQUENCY DRIVERS, open list
The function can return negative values, so its result should
be assigned to signed variable.
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/cpufreq/scpi-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 2c3b16f..de5e89b 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops;
static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
{
- u8 domain = topology_physical_package_id(cpu_dev->id);
+ int domain = topology_physical_package_id(cpu_dev->id);
if (domain < 0)
return ERR_PTR(-EINVAL);
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: linux-arm-kernel
The function can return negative values, so its result should
be assigned to signed variable.
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/cpufreq/scpi-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 2c3b16f..de5e89b 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops;
static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
{
- u8 domain = topology_physical_package_id(cpu_dev->id);
+ int domain = topology_physical_package_id(cpu_dev->id);
if (domain < 0)
return ERR_PTR(-EINVAL);
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Sudeep Holla
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Rafael J. Wysocki, Viresh Kumar,
open list:SYSTEM CONTROL & POWER INTERFACE (SCPI) Message...,
open list:CPU FREQUENCY DRIVERS, open list
The function can return negative values, so its result should
be assigned to signed variable.
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/cpufreq/scpi-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 2c3b16f..de5e89b 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops;
static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
{
- u8 domain = topology_physical_package_id(cpu_dev->id);
+ int domain = topology_physical_package_id(cpu_dev->id);
if (domain < 0)
return ERR_PTR(-EINVAL);
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
2015-12-23 10:37 ` Andrzej Hajda
(?)
@ 2015-12-23 10:37 ` Andrzej Hajda
-1 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Linus Walleij, Ray Jui, Scott Branden, Jon Mason
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:PIN CONTROL SUBSYSTEM,
moderated list:BROADCOM IPROC ARM ARCHITECTURE,
open list:BROADCOM IPROC ARM ARCHITECTURE, open list
Iterator i declared as unsigned is always non-negative so the
loop will never end.
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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
index 34648f6..ad5b04c 100644
--- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
@@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
u16 *strength)
{
- unsigned int i, offset, shift;
+ unsigned int offset, shift;
+ int i;
u32 val;
unsigned long flags;
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: linux-arm-kernel
Iterator i declared as unsigned is always non-negative so the
loop will never end.
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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
index 34648f6..ad5b04c 100644
--- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
@@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
u16 *strength)
{
- unsigned int i, offset, shift;
+ unsigned int offset, shift;
+ int i;
u32 val;
unsigned long flags;
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Linus Walleij, Ray Jui, Scott Branden, Jon Mason
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:PIN CONTROL SUBSYSTEM,
moderated list:BROADCOM IPROC ARM ARCHITECTURE,
open list:BROADCOM IPROC ARM ARCHITECTURE, open list
Iterator i declared as unsigned is always non-negative so the
loop will never end.
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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
index 34648f6..ad5b04c 100644
--- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
@@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
u16 *strength)
{
- unsigned int i, offset, shift;
+ unsigned int offset, shift;
+ int i;
u32 val;
unsigned long flags;
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] NFC: nci: fix handling return value of nci_hci_create_pipe
2015-12-23 10:37 ` Andrzej Hajda
` (2 preceding siblings ...)
(?)
@ 2015-12-23 10:37 ` Andrzej Hajda
-1 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:NFC SUBSYSTEM, open list
The function return NCI_HCI_INVALID_PIPE in case of error.
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>
---
net/nfc/nci/hci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/nfc/nci/hci.c b/net/nfc/nci/hci.c
index 2aedac1..a0ab26d 100644
--- a/net/nfc/nci/hci.c
+++ b/net/nfc/nci/hci.c
@@ -676,7 +676,7 @@ int nci_hci_connect_gate(struct nci_dev *ndev,
break;
default:
pipe = nci_hci_create_pipe(ndev, dest_host, dest_gate, &r);
- if (pipe < 0)
+ if (pipe == NCI_HCI_INVALID_PIPE)
return r;
pipe_created = true;
break;
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-23 10:37 ` Andrzej Hajda
@ 2015-12-23 10:37 ` Andrzej Hajda
-1 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: alsa-devel, Kuninori Morimoto, Bartlomiej Zolnierkiewicz,
open list, Takashi Iwai, Andrzej Hajda, Marek Szyprowski
Field usrcnt is unsigned so it cannot be lesser than zero.
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>
---
sound/soc/sh/rcar/ssi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 0b91692..8ca30fd 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -381,9 +381,9 @@ rsnd_ssi_quit_end:
rsnd_mod_power_off(mod);
- ssi->usrcnt--;
-
- if (ssi->usrcnt < 0)
+ if (ssi->usrcnt > 0)
+ ssi->usrcnt--;
+ else
dev_err(dev, "%s[%d] usrcnt error\n",
rsnd_mod_name(mod), rsnd_mod_id(mod));
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
@ 2015-12-23 10:37 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-23 10:37 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Field usrcnt is unsigned so it cannot be lesser than zero.
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>
---
sound/soc/sh/rcar/ssi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 0b91692..8ca30fd 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -381,9 +381,9 @@ rsnd_ssi_quit_end:
rsnd_mod_power_off(mod);
- ssi->usrcnt--;
-
- if (ssi->usrcnt < 0)
+ if (ssi->usrcnt > 0)
+ ssi->usrcnt--;
+ else
dev_err(dev, "%s[%d] usrcnt error\n",
rsnd_mod_name(mod), rsnd_mod_id(mod));
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
2015-12-23 10:37 ` Andrzej Hajda
@ 2015-12-23 10:41 ` Viresh Kumar
-1 siblings, 0 replies; 29+ messages in thread
From: Viresh Kumar @ 2015-12-23 10:41 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Sudeep Holla, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Rafael J. Wysocki,
open list:SYSTEM CONTROL & POWER INTERFACE (SCPI) Message...,
open list:CPU FREQUENCY DRIVERS, open list
On 23-12-15, 11:37, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> 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/cpufreq/scpi-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
> index 2c3b16f..de5e89b 100644
> --- a/drivers/cpufreq/scpi-cpufreq.c
> +++ b/drivers/cpufreq/scpi-cpufreq.c
> @@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops;
>
> static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
> {
> - u8 domain = topology_physical_package_id(cpu_dev->id);
> + int domain = topology_physical_package_id(cpu_dev->id);
>
> if (domain < 0)
> return ERR_PTR(-EINVAL);
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
@ 2015-12-23 10:41 ` Viresh Kumar
0 siblings, 0 replies; 29+ messages in thread
From: Viresh Kumar @ 2015-12-23 10:41 UTC (permalink / raw)
To: linux-arm-kernel
On 23-12-15, 11:37, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> 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/cpufreq/scpi-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
> index 2c3b16f..de5e89b 100644
> --- a/drivers/cpufreq/scpi-cpufreq.c
> +++ b/drivers/cpufreq/scpi-cpufreq.c
> @@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops;
>
> static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev)
> {
> - u8 domain = topology_physical_package_id(cpu_dev->id);
> + int domain = topology_physical_package_id(cpu_dev->id);
>
> if (domain < 0)
> return ERR_PTR(-EINVAL);
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
2015-12-23 10:37 ` Andrzej Hajda
@ 2015-12-23 10:48 ` Sudeep Holla
-1 siblings, 0 replies; 29+ messages in thread
From: Sudeep Holla @ 2015-12-23 10:48 UTC (permalink / raw)
To: Andrzej Hajda, Rafael J. Wysocki
Cc: Sudeep Holla, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Viresh Kumar,
open list:SYSTEM CONTROL & POWER INTERFACE (SCPI) Message...,
open list:CPU FREQUENCY DRIVERS, open list
On 23/12/15 10:37, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> 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
>
There has a patch posted by Dan Carpenter [1] which I reposted[2],
but it again slipped through the cracks. I will poke Rafael again on that.
[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/380292.html
[2] https://lkml.org/lkml/2015/12/15/219
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id
@ 2015-12-23 10:48 ` Sudeep Holla
0 siblings, 0 replies; 29+ messages in thread
From: Sudeep Holla @ 2015-12-23 10:48 UTC (permalink / raw)
To: linux-arm-kernel
On 23/12/15 10:37, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> 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
>
There has a patch posted by Dan Carpenter [1] which I reposted[2],
but it again slipped through the cracks. I will poke Rafael again on that.
[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/380292.html
[2] https://lkml.org/lkml/2015/12/15/219
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] pinctrl: nsp-gpio: fix type of iterator
2015-12-23 10:37 ` Andrzej Hajda
@ 2015-12-23 22:35 ` Ray Jui
-1 siblings, 0 replies; 29+ messages in thread
From: Ray Jui @ 2015-12-23 22:35 UTC (permalink / raw)
To: Andrzej Hajda, Linus Walleij, Scott Branden, Jon Mason
Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:PIN CONTROL SUBSYSTEM,
moderated list:BROADCOM IPROC ARM ARCHITECTURE,
open list:BROADCOM IPROC ARM ARCHITECTURE, open list,
Yendapally Reddy Dhananjaya Reddy
+ Reddy
On 12/23/2015 2:37 AM, Andrzej Hajda wrote:
> Iterator i declared as unsigned is always non-negative so the
> loop will never end.
>
> 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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> index 34648f6..ad5b04c 100644
> --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> @@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
> static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
> u16 *strength)
> {
> - unsigned int i, offset, shift;
> + unsigned int offset, shift;
> + int i;
> u32 val;
> unsigned long flags;
>
>
The fix is a valid fix. And at the same time it exposes other potential
issues in the driver. I just found the loop used in _set_strength and
_get_strength is inconsistent:
In _set_strength:
427 for (i = GPIO_DRV_STRENGTH_BITS; i > 0; i--) {
For i to start at GPIO_DRV_STRENGTH_BITS, it seems to be wrong.
428 val = readl(chip->io_ctrl + offset);
429 val &= ~BIT(shift);
430 val |= ((strength >> (i-1)) & 0x1) << shift;
431 writel(val, chip->io_ctrl + offset);
432 offset += 4;
433 }
In _get_strength:
451 for (i = (GPIO_DRV_STRENGTH_BITS - 1); i >= 0; i--) {
452 val = readl(chip->io_ctrl + offset) & BIT(shift);
453 val >>= shift;
454 *strength += (val << i);
455 offset += 4;
456 }
Reddy, could you please review and comment?
Thanks,
Ray
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
@ 2015-12-23 22:35 ` Ray Jui
0 siblings, 0 replies; 29+ messages in thread
From: Ray Jui @ 2015-12-23 22:35 UTC (permalink / raw)
To: linux-arm-kernel
+ Reddy
On 12/23/2015 2:37 AM, Andrzej Hajda wrote:
> Iterator i declared as unsigned is always non-negative so the
> loop will never end.
>
> 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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> index 34648f6..ad5b04c 100644
> --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
> @@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
> static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
> u16 *strength)
> {
> - unsigned int i, offset, shift;
> + unsigned int offset, shift;
> + int i;
> u32 val;
> unsigned long flags;
>
>
The fix is a valid fix. And at the same time it exposes other potential
issues in the driver. I just found the loop used in _set_strength and
_get_strength is inconsistent:
In _set_strength:
427 for (i = GPIO_DRV_STRENGTH_BITS; i > 0; i--) {
For i to start at GPIO_DRV_STRENGTH_BITS, it seems to be wrong.
428 val = readl(chip->io_ctrl + offset);
429 val &= ~BIT(shift);
430 val |= ((strength >> (i-1)) & 0x1) << shift;
431 writel(val, chip->io_ctrl + offset);
432 offset += 4;
433 }
In _get_strength:
451 for (i = (GPIO_DRV_STRENGTH_BITS - 1); i >= 0; i--) {
452 val = readl(chip->io_ctrl + offset) & BIT(shift);
453 val >>= shift;
454 *strength += (val << i);
455 offset += 4;
456 }
Reddy, could you please review and comment?
Thanks,
Ray
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-23 10:37 ` Andrzej Hajda
(?)
@ 2015-12-24 0:04 ` Kuninori Morimoto
2015-12-24 5:56 ` Andrzej Hajda
-1 siblings, 1 reply; 29+ messages in thread
From: Kuninori Morimoto @ 2015-12-24 0:04 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Liam Girdwood, Mark Brown, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Hi Andrzej
> Field usrcnt is unsigned so it cannot be lesser than zero.
>
> 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>
> ---
Thank you for your patch. good catch !
I noticed current error case is not good for ssi.c
Can you agree below ?
---------
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 7db05fd..e519e30 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -403,6 +403,12 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct device *dev = rsnd_priv_to_dev(priv);
+ if (!ssi->usrcnt) {
+ dev_err(dev, "%s[%d] usrcnt error\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod));
+ return -EIO;
+ }
+
if (rsnd_ssi_is_parent(mod, io))
goto rsnd_ssi_quit_end;
@@ -422,10 +428,6 @@ rsnd_ssi_quit_end:
ssi->usrcnt--;
- if (ssi->usrcnt < 0)
- dev_err(dev, "%s[%d] usrcnt error\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod));
-
return 0;
}
---------
Best regards
---
Kuninori Morimoto
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH] pinctrl: nsp-gpio: fix type of iterator
2015-12-23 22:35 ` Ray Jui
@ 2015-12-24 5:33 ` Yendapally Reddy Dhananjaya Reddy
-1 siblings, 0 replies; 29+ messages in thread
From: Yendapally Reddy Dhananjaya Reddy @ 2015-12-24 5:33 UTC (permalink / raw)
To: Ray Jui, Andrzej Hajda, Linus Walleij, Scott Branden, Jon Mason
Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski,
open list:PIN CONTROL SUBSYSTEM,
moderated list:BROADCOM IPROC ARM ARCHITECTURE,
bcm-kernel-feedback-list, open list
On 12/24/2015 4:05 AM, Ray Jui wrote:
> + Reddy
>
> On 12/23/2015 2:37 AM, Andrzej Hajda wrote:
>> Iterator i declared as unsigned is always non-negative so the
>> loop will never end.
>>
>> 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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> index 34648f6..ad5b04c 100644
>> --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> @@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
>> static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
>> u16 *strength)
>> {
>> - unsigned int i, offset, shift;
>> + unsigned int offset, shift;
>> + int i;
>> u32 val;
>> unsigned long flags;
>>
>>
> The fix is a valid fix. And at the same time it exposes other potential
> issues in the driver. I just found the loop used in _set_strength and
> _get_strength is inconsistent:
>
> In _set_strength:
>
> 427 for (i = GPIO_DRV_STRENGTH_BITS; i > 0; i--) {
>
> For i to start at GPIO_DRV_STRENGTH_BITS, it seems to be wrong.
>
> 428 val = readl(chip->io_ctrl + offset);
> 429 val &= ~BIT(shift);
> 430 val |= ((strength >> (i-1)) & 0x1) << shift;
> 431 writel(val, chip->io_ctrl + offset);
> 432 offset += 4;
> 433 }
>
> In _get_strength:
>
> 451 for (i = (GPIO_DRV_STRENGTH_BITS - 1); i >= 0; i--) {
> 452 val = readl(chip->io_ctrl + offset) & BIT(shift);
> 453 val >>= shift;
> 454 *strength += (val << i);
> 455 offset += 4;
> 456 }
>
> Reddy, could you please review and comment?
Hi Ray,
The logic is correct. The drive strength has three bits distributed in three registers. In one case the "-1" is in for loop initialization and the other case it is in the for loop body. The fix looks good.
Thanks
Dhananjay
> Thanks,
>
> Ray
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
@ 2015-12-24 5:33 ` Yendapally Reddy Dhananjaya Reddy
0 siblings, 0 replies; 29+ messages in thread
From: Yendapally Reddy Dhananjaya Reddy @ 2015-12-24 5:33 UTC (permalink / raw)
To: linux-arm-kernel
On 12/24/2015 4:05 AM, Ray Jui wrote:
> + Reddy
>
> On 12/23/2015 2:37 AM, Andrzej Hajda wrote:
>> Iterator i declared as unsigned is always non-negative so the
>> loop will never end.
>>
>> 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/pinctrl/bcm/pinctrl-nsp-gpio.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> index 34648f6..ad5b04c 100644
>> --- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> +++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
>> @@ -439,7 +439,8 @@ static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
>> static int nsp_gpio_get_strength(struct nsp_gpio *chip, unsigned gpio,
>> u16 *strength)
>> {
>> - unsigned int i, offset, shift;
>> + unsigned int offset, shift;
>> + int i;
>> u32 val;
>> unsigned long flags;
>>
>>
> The fix is a valid fix. And at the same time it exposes other potential
> issues in the driver. I just found the loop used in _set_strength and
> _get_strength is inconsistent:
>
> In _set_strength:
>
> 427 for (i = GPIO_DRV_STRENGTH_BITS; i > 0; i--) {
>
> For i to start at GPIO_DRV_STRENGTH_BITS, it seems to be wrong.
>
> 428 val = readl(chip->io_ctrl + offset);
> 429 val &= ~BIT(shift);
> 430 val |= ((strength >> (i-1)) & 0x1) << shift;
> 431 writel(val, chip->io_ctrl + offset);
> 432 offset += 4;
> 433 }
>
> In _get_strength:
>
> 451 for (i = (GPIO_DRV_STRENGTH_BITS - 1); i >= 0; i--) {
> 452 val = readl(chip->io_ctrl + offset) & BIT(shift);
> 453 val >>= shift;
> 454 *strength += (val << i);
> 455 offset += 4;
> 456 }
>
> Reddy, could you please review and comment?
Hi Ray,
The logic is correct. The drive strength has three bits distributed in three registers. In one case the "-1" is in for loop initialization and the other case it is in the for loop body. The fix looks good.
Thanks
Dhananjay
> Thanks,
>
> Ray
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-24 0:04 ` Kuninori Morimoto
@ 2015-12-24 5:56 ` Andrzej Hajda
2015-12-24 6:14 ` Kuninori Morimoto
0 siblings, 1 reply; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-24 5:56 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Liam Girdwood, Mark Brown, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
On 12/24/2015 01:04 AM, Kuninori Morimoto wrote:
> Hi Andrzej
>
>> Field usrcnt is unsigned so it cannot be lesser than zero.
>>
>> 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>
>> ---
> Thank you for your patch. good catch !
> I noticed current error case is not good for ssi.c
> Can you agree below ?
Yes, of course.
Regards
Andrzej
>
> ---------
> diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
> index 7db05fd..e519e30 100644
> --- a/sound/soc/sh/rcar/ssi.c
> +++ b/sound/soc/sh/rcar/ssi.c
> @@ -403,6 +403,12 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
> struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
> struct device *dev = rsnd_priv_to_dev(priv);
>
> + if (!ssi->usrcnt) {
> + dev_err(dev, "%s[%d] usrcnt error\n",
> + rsnd_mod_name(mod), rsnd_mod_id(mod));
> + return -EIO;
> + }
> +
> if (rsnd_ssi_is_parent(mod, io))
> goto rsnd_ssi_quit_end;
>
> @@ -422,10 +428,6 @@ rsnd_ssi_quit_end:
>
> ssi->usrcnt--;
>
> - if (ssi->usrcnt < 0)
> - dev_err(dev, "%s[%d] usrcnt error\n",
> - rsnd_mod_name(mod), rsnd_mod_id(mod));
> -
> return 0;
> }
>
> ---------
>
>
> Best regards
> ---
> Kuninori Morimoto
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-24 5:56 ` Andrzej Hajda
@ 2015-12-24 6:14 ` Kuninori Morimoto
0 siblings, 0 replies; 29+ messages in thread
From: Kuninori Morimoto @ 2015-12-24 6:14 UTC (permalink / raw)
To: Andrzej Hajda
Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
Liam Girdwood, open list, Bartlomiej Zolnierkiewicz, Takashi Iwai,
Mark Brown, Marek Szyprowski
Hi Andrzej
> >> Field usrcnt is unsigned so it cannot be lesser than zero.
> >>
> >> 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>
> >> ---
> > Thank you for your patch. good catch !
> > I noticed current error case is not good for ssi.c
> > Can you agree below ?
> Yes, of course.
Thanks.
Who send this patch ? you or me ?
I think you can do it ?
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
@ 2015-12-24 6:14 ` Kuninori Morimoto
0 siblings, 0 replies; 29+ messages in thread
From: Kuninori Morimoto @ 2015-12-24 6:14 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Liam Girdwood, Mark Brown, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Hi Andrzej
> >> Field usrcnt is unsigned so it cannot be lesser than zero.
> >>
> >> 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>
> >> ---
> > Thank you for your patch. good catch !
> > I noticed current error case is not good for ssi.c
> > Can you agree below ?
> Yes, of course.
Thanks.
Who send this patch ? you or me ?
I think you can do it ?
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v2] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-24 6:14 ` Kuninori Morimoto
@ 2015-12-24 7:02 ` Andrzej Hajda
-1 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-24 7:02 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Kuninori Morimoto
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Field usrcnt is unsigned so it cannot be lesser than zero.
The patch fixes the check, moves it to the beginning of the function
and changes return value to -EIO in case of usercnt error.
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>
---
v2: changed according to Kuninori Morimoto advice
---
sound/soc/sh/rcar/ssi.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 0b91692..f23c921 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -364,29 +364,30 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct device *dev = rsnd_priv_to_dev(priv);
- if (rsnd_ssi_is_parent(mod, io))
- goto rsnd_ssi_quit_end;
+ if (!ssi->usrcnt) {
+ dev_err(dev, "%s[%d] usrcnt error\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod));
+ return -EIO;
+ }
- if (ssi->err > 0)
- dev_warn(dev, "%s[%d] under/over flow err = %d\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod), ssi->err);
+ if (!rsnd_ssi_is_parent(mod, io)) {
+ if (ssi->err > 0)
+ dev_warn(dev, "%s[%d] under/over flow err = %d\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod),
+ ssi->err);
- ssi->cr_own = 0;
- ssi->err = 0;
+ ssi->cr_own = 0;
+ ssi->err = 0;
- rsnd_ssi_irq_disable(mod);
+ rsnd_ssi_irq_disable(mod);
+ }
-rsnd_ssi_quit_end:
rsnd_ssi_master_clk_stop(ssi, io);
rsnd_mod_power_off(mod);
ssi->usrcnt--;
- if (ssi->usrcnt < 0)
- dev_err(dev, "%s[%d] usrcnt error\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod));
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH v2] ASoC: rsnd: fix usrcnt decrementing bug
@ 2015-12-24 7:02 ` Andrzej Hajda
0 siblings, 0 replies; 29+ messages in thread
From: Andrzej Hajda @ 2015-12-24 7:02 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Kuninori Morimoto
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Field usrcnt is unsigned so it cannot be lesser than zero.
The patch fixes the check, moves it to the beginning of the function
and changes return value to -EIO in case of usercnt error.
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>
---
v2: changed according to Kuninori Morimoto advice
---
sound/soc/sh/rcar/ssi.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 0b91692..f23c921 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -364,29 +364,30 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct device *dev = rsnd_priv_to_dev(priv);
- if (rsnd_ssi_is_parent(mod, io))
- goto rsnd_ssi_quit_end;
+ if (!ssi->usrcnt) {
+ dev_err(dev, "%s[%d] usrcnt error\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod));
+ return -EIO;
+ }
- if (ssi->err > 0)
- dev_warn(dev, "%s[%d] under/over flow err = %d\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod), ssi->err);
+ if (!rsnd_ssi_is_parent(mod, io)) {
+ if (ssi->err > 0)
+ dev_warn(dev, "%s[%d] under/over flow err = %d\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod),
+ ssi->err);
- ssi->cr_own = 0;
- ssi->err = 0;
+ ssi->cr_own = 0;
+ ssi->err = 0;
- rsnd_ssi_irq_disable(mod);
+ rsnd_ssi_irq_disable(mod);
+ }
-rsnd_ssi_quit_end:
rsnd_ssi_master_clk_stop(ssi, io);
rsnd_mod_power_off(mod);
ssi->usrcnt--;
- if (ssi->usrcnt < 0)
- dev_err(dev, "%s[%d] usrcnt error\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod));
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v2] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-24 7:02 ` Andrzej Hajda
(?)
@ 2015-12-24 7:38 ` Kuninori Morimoto
-1 siblings, 0 replies; 29+ messages in thread
From: Kuninori Morimoto @ 2015-12-24 7:38 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Liam Girdwood, Mark Brown, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
Hi
>
> Field usrcnt is unsigned so it cannot be lesser than zero.
> The patch fixes the check, moves it to the beginning of the function
> and changes return value to -EIO in case of usercnt error.
>
> 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>
> ---
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH] pinctrl: nsp-gpio: fix type of iterator
2015-12-23 10:37 ` Andrzej Hajda
@ 2015-12-24 9:03 ` Linus Walleij
-1 siblings, 0 replies; 29+ messages in thread
From: Linus Walleij @ 2015-12-24 9:03 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Ray Jui, Scott Branden, Jon Mason, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, open list:PIN CONTROL SUBSYSTEM,
moderated list:BROADCOM IPROC ARM ARCHITECTURE,
open list:BROADCOM IPROC ARM ARCHITECTURE, open list
On Wed, Dec 23, 2015 at 11:37 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> Iterator i declared as unsigned is always non-negative so the
> loop will never end.
>
> 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>
I already applied Dan Carpenters fix, somehow it was earlier
in my mail flow. Thanks anyways!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH] pinctrl: nsp-gpio: fix type of iterator
@ 2015-12-24 9:03 ` Linus Walleij
0 siblings, 0 replies; 29+ messages in thread
From: Linus Walleij @ 2015-12-24 9:03 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Dec 23, 2015 at 11:37 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> Iterator i declared as unsigned is always non-negative so the
> loop will never end.
>
> 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>
I already applied Dan Carpenters fix, somehow it was earlier
in my mail flow. Thanks anyways!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2] ASoC: rsnd: fix usrcnt decrementing bug
2015-12-24 7:02 ` Andrzej Hajda
@ 2015-12-30 17:12 ` Mark Brown
-1 siblings, 0 replies; 29+ messages in thread
From: Mark Brown @ 2015-12-30 17:12 UTC (permalink / raw)
To: Andrzej Hajda
Cc: moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
Kuninori Morimoto, Liam Girdwood, open list,
Bartlomiej Zolnierkiewicz, Takashi Iwai, Marek Szyprowski
[-- Attachment #1.1: Type: text/plain, Size: 379 bytes --]
On Thu, Dec 24, 2015 at 08:02:39AM +0100, Andrzej Hajda wrote:
> Field usrcnt is unsigned so it cannot be lesser than zero.
> The patch fixes the check, moves it to the beginning of the function
> and changes return value to -EIO in case of usercnt error.
Please don't send new patches in reply to old ones, it makes it hard to
figure out what the current version of things is.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v2] ASoC: rsnd: fix usrcnt decrementing bug
@ 2015-12-30 17:12 ` Mark Brown
0 siblings, 0 replies; 29+ messages in thread
From: Mark Brown @ 2015-12-30 17:12 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Liam Girdwood, Kuninori Morimoto, Bartlomiej Zolnierkiewicz,
Marek Szyprowski, Jaroslav Kysela, Takashi Iwai,
moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
open list
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
On Thu, Dec 24, 2015 at 08:02:39AM +0100, Andrzej Hajda wrote:
> Field usrcnt is unsigned so it cannot be lesser than zero.
> The patch fixes the check, moves it to the beginning of the function
> and changes return value to -EIO in case of usercnt error.
Please don't send new patches in reply to old ones, it makes it hard to
figure out what the current version of things is.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Applied "ASoC: rsnd: fix usrcnt decrementing bug" to the asoc tree
2015-12-24 7:02 ` Andrzej Hajda
` (2 preceding siblings ...)
(?)
@ 2015-12-30 18:05 ` Mark Brown
-1 siblings, 0 replies; 29+ messages in thread
From: Mark Brown @ 2015-12-30 18:05 UTC (permalink / raw)
To: Andrzej Hajda, Kuninori Morimoto, Mark Brown; +Cc: alsa-devel
The patch
ASoC: rsnd: fix usrcnt decrementing bug
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From e5d9cfc6f5fe56caa44cefbc7ef4531c480d901d Mon Sep 17 00:00:00 2001
From: Andrzej Hajda <a.hajda@samsung.com>
Date: Thu, 24 Dec 2015 08:02:39 +0100
Subject: [PATCH] ASoC: rsnd: fix usrcnt decrementing bug
Field usrcnt is unsigned so it cannot be lesser than zero.
The patch fixes the check, moves it to the beginning of the function
and changes return value to -EIO in case of usercnt error.
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>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/sh/rcar/ssi.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 7db05fdfb656..7ee89da4dd5f 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -403,29 +403,30 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct device *dev = rsnd_priv_to_dev(priv);
- if (rsnd_ssi_is_parent(mod, io))
- goto rsnd_ssi_quit_end;
+ if (!ssi->usrcnt) {
+ dev_err(dev, "%s[%d] usrcnt error\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod));
+ return -EIO;
+ }
- if (ssi->err > 0)
- dev_warn(dev, "%s[%d] under/over flow err = %d\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod), ssi->err);
+ if (!rsnd_ssi_is_parent(mod, io)) {
+ if (ssi->err > 0)
+ dev_warn(dev, "%s[%d] under/over flow err = %d\n",
+ rsnd_mod_name(mod), rsnd_mod_id(mod),
+ ssi->err);
- ssi->cr_own = 0;
- ssi->err = 0;
+ ssi->cr_own = 0;
+ ssi->err = 0;
- rsnd_ssi_irq_disable(mod);
+ rsnd_ssi_irq_disable(mod);
+ }
-rsnd_ssi_quit_end:
rsnd_ssi_master_clk_stop(ssi, io);
rsnd_mod_power_off(mod);
ssi->usrcnt--;
- if (ssi->usrcnt < 0)
- dev_err(dev, "%s[%d] usrcnt error\n",
- rsnd_mod_name(mod), rsnd_mod_id(mod));
-
return 0;
}
--
2.6.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
end of thread, other threads:[~2015-12-30 18:05 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-23 10:37 [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id Andrzej Hajda
2015-12-23 10:37 ` Andrzej Hajda
2015-12-23 10:37 ` Andrzej Hajda
2015-12-23 10:37 ` [PATCH] pinctrl: nsp-gpio: fix type of iterator Andrzej Hajda
2015-12-23 10:37 ` Andrzej Hajda
2015-12-23 10:37 ` Andrzej Hajda
2015-12-23 22:35 ` Ray Jui
2015-12-23 22:35 ` Ray Jui
2015-12-24 5:33 ` Yendapally Reddy Dhananjaya Reddy
2015-12-24 5:33 ` Yendapally Reddy Dhananjaya Reddy
2015-12-24 9:03 ` Linus Walleij
2015-12-24 9:03 ` Linus Walleij
2015-12-23 10:37 ` [PATCH] NFC: nci: fix handling return value of nci_hci_create_pipe Andrzej Hajda
2015-12-23 10:37 ` [PATCH] ASoC: rsnd: fix usrcnt decrementing bug Andrzej Hajda
2015-12-23 10:37 ` Andrzej Hajda
2015-12-24 0:04 ` Kuninori Morimoto
2015-12-24 5:56 ` Andrzej Hajda
2015-12-24 6:14 ` Kuninori Morimoto
2015-12-24 6:14 ` Kuninori Morimoto
2015-12-24 7:02 ` [PATCH v2] " Andrzej Hajda
2015-12-24 7:02 ` Andrzej Hajda
2015-12-24 7:38 ` Kuninori Morimoto
2015-12-30 17:12 ` Mark Brown
2015-12-30 17:12 ` Mark Brown
2015-12-30 18:05 ` Applied "ASoC: rsnd: fix usrcnt decrementing bug" to the asoc tree Mark Brown
2015-12-23 10:41 ` [PATCH] cpufreq/scpi: fix handling return value of topology_physical_package_id Viresh Kumar
2015-12-23 10:41 ` Viresh Kumar
2015-12-23 10:48 ` Sudeep Holla
2015-12-23 10:48 ` Sudeep Holla
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.