Skip to content

Commit

Permalink
remoteproc: st: Fix sometimes uninitialized ret in st_rproc_probe()
Browse files Browse the repository at this point in the history
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: 5c77ebc ("remoteproc: st: Use device_get_match_data()")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20231012-st_remoteproc-fix-sometimes-uninit-v1-1-f64d0f2d5b37@kernel.org
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
  • Loading branch information
Nathan Chancellor authored and Mathieu Poirier committed Oct 16, 2023
1 parent 5c77ebc commit 3d8a186
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/remoteproc/st_remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3d8a186

Please sign in to comment.