fs: semihosting: Use correct variable for error check mainline origin/mainline
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 2 Oct 2025 09:39:58 +0000 (10:39 +0100)
committerTom Rini <trini@konsulko.com>
Sat, 18 Oct 2025 00:07:20 +0000 (18:07 -0600)
After calling a function that can return an error, the test to detect
that error should use the return value not a different variable. Fix it.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
Fixes: f676b45151c3 ("fs: Add semihosting filesystem")

fs/semihostingfs.c

index 77e39ca..9d7a136 100644 (file)
@@ -35,7 +35,7 @@ static int smh_fs_read_at(const char *filename, loff_t pos, void *buffer,
        }
        if (!maxsize) {
                size = smh_flen(fd);
-               if (ret < 0) {
+               if (size < 0) {
                        smh_close(fd);
                        return size;
                }