* [PATCH] thermal/drivers/tsens: fix usage of unititialized value
@ 2021-06-08 9:41 Yang Li
2021-06-11 11:50 ` Thara Gopinath
0 siblings, 1 reply; 2+ messages in thread
From: Yang Li @ 2021-06-08 9:41 UTC (permalink / raw)
To: amitk
Cc: thara.gopinath, agross, bjorn.andersson, rui.zhang,
daniel.lezcano, linux-pm, linux-arm-msm, linux-kernel, Yang Li
When "tsens_version(priv) > VER_0_1" is false,
"regmap_field_read(priv->rf[VER_MINOR], &ver_minor)" can't execute.
So, ver_minor has no initialization and assignment before it is
used, and we initialize it to 0.
Clean up smatch warning:
drivers/thermal/qcom/tsens.c:896 init_common() error: uninitialized
symbol 'ver_minor'.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
drivers/thermal/qcom/tsens.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 4c7ebd1..a36c43d 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -743,8 +743,8 @@ int __init init_common(struct tsens_priv *priv)
{
void __iomem *tm_base, *srot_base;
struct device *dev = priv->dev;
- u32 ver_minor;
struct resource *res;
+ u32 ver_minor = 0;
u32 enabled;
int ret, i, j;
struct platform_device *op = of_find_device_by_node(priv->dev->of_node);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thermal/drivers/tsens: fix usage of unititialized value
2021-06-08 9:41 [PATCH] thermal/drivers/tsens: fix usage of unititialized value Yang Li
@ 2021-06-11 11:50 ` Thara Gopinath
0 siblings, 0 replies; 2+ messages in thread
From: Thara Gopinath @ 2021-06-11 11:50 UTC (permalink / raw)
To: Yang Li, amitk
Cc: agross, bjorn.andersson, rui.zhang, daniel.lezcano, linux-pm,
linux-arm-msm, linux-kernel
On 6/8/21 5:41 AM, Yang Li wrote:
> When "tsens_version(priv) > VER_0_1" is false,
> "regmap_field_read(priv->rf[VER_MINOR], &ver_minor)" can't execute.
> So, ver_minor has no initialization and assignment before it is
> used, and we initialize it to 0.
Hi Yang,
Thanks for the patch. I have a few questions though.
1. Where do you see ver_minor being used uninitialized? AFAICT ,
ver_minor is used like below and will never be referenced if version <=
VER_0_1
if (tsens_version(priv) > VER_1_X && ver_minor > 2) {
2. Do you know whether minor versions can be read or not on tsens ips
with verions < 0_1?
--
Warm Regards
Thara (She/Her/Hers)
>
> Clean up smatch warning:
> drivers/thermal/qcom/tsens.c:896 init_common() error: uninitialized
> symbol 'ver_minor'.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
> drivers/thermal/qcom/tsens.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 4c7ebd1..a36c43d 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -743,8 +743,8 @@ int __init init_common(struct tsens_priv *priv)
> {
> void __iomem *tm_base, *srot_base;
> struct device *dev = priv->dev;
> - u32 ver_minor;
> struct resource *res;
> + u32 ver_minor = 0;
> u32 enabled;
> int ret, i, j;
> struct platform_device *op = of_find_device_by_node(priv->dev->of_node);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-11 11:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 9:41 [PATCH] thermal/drivers/tsens: fix usage of unititialized value Yang Li
2021-06-11 11:50 ` Thara Gopinath
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).