Message ID | 1450867041-729-1-git-send-email-a.hajda@samsung.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
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>
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
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);
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(-)