Skip to content

Commit c08f3a8

Browse files
computersforpeacegregkh
authored andcommitted
test: firmware_class: report errors properly on failure
commit 47e0bbb7fa985a0f1b5794a8653fae4f8f49de77 upstream. request_firmware() failures currently won't get reported at all (the error code is discarded). What's more, we get confusing messages, like: # echo -n notafile > /sys/devices/virtual/misc/test_firmware/trigger_request [ 8280.311856] test_firmware: loading 'notafile' [ 8280.317042] test_firmware: load of 'notafile' failed: -2 [ 8280.322445] test_firmware: loaded: 0 # echo $? 0 Report the failures via write() errors, and don't say we "loaded" anything. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6004eb4 commit c08f3a8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lib/test_firmware.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,19 @@ static ssize_t trigger_request_store(struct device *dev,
6565
release_firmware(test_firmware);
6666
test_firmware = NULL;
6767
rc = request_firmware(&test_firmware, name, dev);
68-
if (rc)
68+
if (rc) {
6969
pr_info("load of '%s' failed: %d\n", name, rc);
70-
pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0);
70+
goto out;
71+
}
72+
pr_info("loaded: %zu\n", test_firmware->size);
73+
rc = count;
74+
75+
out:
7176
mutex_unlock(&test_fw_mutex);
7277

7378
kfree(name);
7479

75-
return count;
80+
return rc;
7681
}
7782
static DEVICE_ATTR_WO(trigger_request);
7883

0 commit comments

Comments
 (0)