* [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe()
@ 2023-10-12 17:04 Nathan Chancellor
2023-10-13 20:36 ` Nick Desaulniers
2023-10-16 17:29 ` Mathieu Poirier
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-10-12 17:04 UTC (permalink / raw)
To: patrice.chotard, andersson, mathieu.poirier, robh
Cc: ndesaulniers, trix, linux-arm-kernel, linux-remoteproc, llvm,
patches, Nathan Chancellor
Clang warns (or errors with CONFIG_WERROR=y):
drivers/remoteproc/st_remoteproc.c:357:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
357 | if (!ddata->config)
| ^~~~~~~~~~~~~~
drivers/remoteproc/st_remoteproc.c:442:9: note: uninitialized use occurs here
442 | return ret;
| ^~~
drivers/remoteproc/st_remoteproc.c:357:2: note: remove the 'if' if its condition is always false
357 | if (!ddata->config)
| ^~~~~~~~~~~~~~~~~~~
358 | goto free_rproc;
| ~~~~~~~~~~~~~~~
drivers/remoteproc/st_remoteproc.c:348:9: note: initialize the variable 'ret' to silence this warning
348 | int ret, i;
| ^
| = 0
1 error generated.
Set ret to -ENODEV, which seems to be a standard return code when
device_get_match_data() returns NULL.
Closes: https://github.com/ClangBuiltLinux/linux/issues/1944
Fixes: 5c77ebcd05ac ("remoteproc: st: Use device_get_match_data()")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/remoteproc/st_remoteproc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
index b0638f984842..cb163766c56d 100644
--- a/drivers/remoteproc/st_remoteproc.c
+++ b/drivers/remoteproc/st_remoteproc.c
@@ -354,8 +354,10 @@ static int st_rproc_probe(struct platform_device *pdev)
rproc->has_iommu = false;
ddata = rproc->priv;
ddata->config = (struct st_rproc_config *)device_get_match_data(dev);
- if (!ddata->config)
+ if (!ddata->config) {
+ ret = -ENODEV;
goto free_rproc;
+ }
platform_set_drvdata(pdev, rproc);
---
base-commit: 5c77ebcd05acf3789949c8a387df72381d949ca2
change-id: 20231012-st_remoteproc-fix-sometimes-uninit-7aff1bdb7349
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe()
2023-10-12 17:04 [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe() Nathan Chancellor
@ 2023-10-13 20:36 ` Nick Desaulniers
2023-10-16 17:29 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2023-10-13 20:36 UTC (permalink / raw)
To: Nathan Chancellor
Cc: patrice.chotard, andersson, mathieu.poirier, robh, trix,
linux-arm-kernel, linux-remoteproc, llvm, patches
On Thu, Oct 12, 2023 at 10:04 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Clang warns (or errors with CONFIG_WERROR=y):
>
> drivers/remoteproc/st_remoteproc.c:357:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> 357 | if (!ddata->config)
> | ^~~~~~~~~~~~~~
> drivers/remoteproc/st_remoteproc.c:442:9: note: uninitialized use occurs here
> 442 | return ret;
> | ^~~
> drivers/remoteproc/st_remoteproc.c:357:2: note: remove the 'if' if its condition is always false
> 357 | if (!ddata->config)
> | ^~~~~~~~~~~~~~~~~~~
> 358 | goto free_rproc;
> | ~~~~~~~~~~~~~~~
> drivers/remoteproc/st_remoteproc.c:348:9: note: initialize the variable 'ret' to silence this warning
> 348 | int ret, i;
> | ^
> | = 0
> 1 error generated.
>
> Set ret to -ENODEV, which seems to be a standard return code when
> device_get_match_data() returns NULL.
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/1944
> Fixes: 5c77ebcd05ac ("remoteproc: st: Use device_get_match_data()")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> drivers/remoteproc/st_remoteproc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
> index b0638f984842..cb163766c56d 100644
> --- a/drivers/remoteproc/st_remoteproc.c
> +++ b/drivers/remoteproc/st_remoteproc.c
> @@ -354,8 +354,10 @@ static int st_rproc_probe(struct platform_device *pdev)
> rproc->has_iommu = false;
> ddata = rproc->priv;
> ddata->config = (struct st_rproc_config *)device_get_match_data(dev);
> - if (!ddata->config)
> + if (!ddata->config) {
> + ret = -ENODEV;
> goto free_rproc;
> + }
>
> platform_set_drvdata(pdev, rproc);
>
>
> ---
> base-commit: 5c77ebcd05acf3789949c8a387df72381d949ca2
> change-id: 20231012-st_remoteproc-fix-sometimes-uninit-7aff1bdb7349
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
--
Thanks,
~Nick Desaulniers
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe()
2023-10-12 17:04 [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe() Nathan Chancellor
2023-10-13 20:36 ` Nick Desaulniers
@ 2023-10-16 17:29 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2023-10-16 17:29 UTC (permalink / raw)
To: Nathan Chancellor
Cc: patrice.chotard, andersson, robh, ndesaulniers, trix,
linux-arm-kernel, linux-remoteproc, llvm, patches
On Thu, Oct 12, 2023 at 10:04:01AM -0700, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR=y):
>
> drivers/remoteproc/st_remoteproc.c:357:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> 357 | if (!ddata->config)
> | ^~~~~~~~~~~~~~
> drivers/remoteproc/st_remoteproc.c:442:9: note: uninitialized use occurs here
> 442 | return ret;
> | ^~~
> drivers/remoteproc/st_remoteproc.c:357:2: note: remove the 'if' if its condition is always false
> 357 | if (!ddata->config)
> | ^~~~~~~~~~~~~~~~~~~
> 358 | goto free_rproc;
> | ~~~~~~~~~~~~~~~
> drivers/remoteproc/st_remoteproc.c:348:9: note: initialize the variable 'ret' to silence this warning
> 348 | int ret, i;
> | ^
> | = 0
> 1 error generated.
>
> Set ret to -ENODEV, which seems to be a standard return code when
> device_get_match_data() returns NULL.
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/1944
> Fixes: 5c77ebcd05ac ("remoteproc: st: Use device_get_match_data()")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/remoteproc/st_remoteproc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
> index b0638f984842..cb163766c56d 100644
> --- a/drivers/remoteproc/st_remoteproc.c
> +++ b/drivers/remoteproc/st_remoteproc.c
> @@ -354,8 +354,10 @@ static int st_rproc_probe(struct platform_device *pdev)
> rproc->has_iommu = false;
> ddata = rproc->priv;
> ddata->config = (struct st_rproc_config *)device_get_match_data(dev);
> - if (!ddata->config)
> + if (!ddata->config) {
> + ret = -ENODEV;
Applied and thanks for fixing this.
Mathieu
> goto free_rproc;
> + }
>
> platform_set_drvdata(pdev, rproc);
>
>
> ---
> base-commit: 5c77ebcd05acf3789949c8a387df72381d949ca2
> change-id: 20231012-st_remoteproc-fix-sometimes-uninit-7aff1bdb7349
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-16 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 17:04 [PATCH] remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe() Nathan Chancellor
2023-10-13 20:36 ` Nick Desaulniers
2023-10-16 17:29 ` Mathieu Poirier
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).