From: Brian Norris <computersforpeace@gmail.com> To: Shuah Khan <shuahkh@osg.samsung.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Ming Lei <ming.lei@canonical.com> Cc: Kees Cook <keescook@chromium.org>, Brian Norris <computersforpeace@gmail.com>, <linux-kernel@vger.kernel.org>, <linux-api@vger.kernel.org>, "Luis R. Rodriguez" <mcgrof@suse.com> Subject: [PATCH v2 1/5] test: firmware_class: report errors properly on failure Date: Wed, 9 Dec 2015 14:50:25 -0800 [thread overview] Message-ID: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> (raw) 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> --- v2: no change v1: thread starts here: https://lkml.org/lkml/2015/12/8/816 lib/test_firmware.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/test_firmware.c b/lib/test_firmware.c index 86374c1c49a4..841191061816 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -65,14 +65,19 @@ static ssize_t trigger_request_store(struct device *dev, release_firmware(test_firmware); test_firmware = NULL; rc = request_firmware(&test_firmware, name, dev); - if (rc) + if (rc) { pr_info("load of '%s' failed: %d\n", name, rc); - pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0); + goto out; + } + pr_info("loaded: %zu\n", test_firmware->size); + rc = count; + +out: mutex_unlock(&test_fw_mutex); kfree(name); - return count; + return rc; } static DEVICE_ATTR_WO(trigger_request); -- 2.6.0.rc2.230.g3dd15c0
WARNING: multiple messages have this Message-ID (diff)
From: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: Shuah Khan <shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>, Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>, Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> Cc: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>, Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Luis R. Rodriguez" <mcgrof-IBi9RG/b67k@public.gmane.org> Subject: [PATCH v2 1/5] test: firmware_class: report errors properly on failure Date: Wed, 9 Dec 2015 14:50:25 -0800 [thread overview] Message-ID: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> (raw) 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Acked-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> --- v2: no change v1: thread starts here: https://lkml.org/lkml/2015/12/8/816 lib/test_firmware.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/test_firmware.c b/lib/test_firmware.c index 86374c1c49a4..841191061816 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -65,14 +65,19 @@ static ssize_t trigger_request_store(struct device *dev, release_firmware(test_firmware); test_firmware = NULL; rc = request_firmware(&test_firmware, name, dev); - if (rc) + if (rc) { pr_info("load of '%s' failed: %d\n", name, rc); - pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0); + goto out; + } + pr_info("loaded: %zu\n", test_firmware->size); + rc = count; + +out: mutex_unlock(&test_fw_mutex); kfree(name); - return count; + return rc; } static DEVICE_ATTR_WO(trigger_request); -- 2.6.0.rc2.230.g3dd15c0
next reply other threads:[~2015-12-09 22:50 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-12-09 22:50 Brian Norris [this message] 2015-12-09 22:50 ` [PATCH v2 1/5] test: firmware_class: report errors properly on failure Brian Norris 2015-12-09 22:50 ` [PATCH v2 2/5] test: firmware_class: use kstrndup() where appropriate Brian Norris 2015-12-09 22:50 ` Brian Norris 2016-01-07 20:55 ` Shuah Khan 2016-01-07 20:55 ` Shuah Khan 2015-12-09 22:50 ` [PATCH v2 3/5] test: firmware_class: add asynchronous request trigger Brian Norris 2015-12-09 22:50 ` Brian Norris 2015-12-09 23:22 ` Kees Cook 2015-12-09 23:22 ` Kees Cook 2016-01-07 20:56 ` Shuah Khan 2015-12-09 22:50 ` [PATCH v2 4/5] firmware: actually return NULL on failed request_firmware_nowait() Brian Norris 2015-12-09 22:50 ` Brian Norris 2015-12-21 19:06 ` Luis R. Rodriguez 2016-01-07 20:56 ` Shuah Khan 2016-01-07 20:56 ` Shuah Khan 2015-12-09 22:50 ` [PATCH v2 5/5] selftests: firmware: add empty string and async tests Brian Norris 2015-12-09 22:50 ` Brian Norris 2016-01-07 20:57 ` Shuah Khan 2016-01-07 20:57 ` Shuah Khan 2016-01-07 21:39 ` Brian Norris 2016-01-07 21:39 ` Brian Norris 2016-01-07 21:42 ` Shuah Khan 2016-01-07 21:42 ` Shuah Khan 2016-01-07 20:54 ` [PATCH v2 1/5] test: firmware_class: report errors properly on failure Shuah Khan 2016-01-07 20:54 ` Shuah Khan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1449701429-121423-1-git-send-email-computersforpeace@gmail.com \ --to=computersforpeace@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=keescook@chromium.org \ --cc=linux-api@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mcgrof@suse.com \ --cc=ming.lei@canonical.com \ --cc=shuahkh@osg.samsung.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.