]> git.karo-electronics.de Git - linux-beck.git/commitdiff
firmware_class: make sure fw requests contain a name
authorKees Cook <keescook@chromium.org>
Thu, 18 Sep 2014 18:25:37 +0000 (11:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Sep 2014 06:26:58 +0000 (23:26 -0700)
An empty firmware request name will trigger warnings when building
device names. Make sure this is caught earlier and rejected.

The warning was visible via the test_firmware.ko module interface:

echo -ne "\x00" > /sys/devices/virtual/misc/test_firmware/trigger_request

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/firmware_class.c

index bf424305f3dc3c6c04cc4fbe621601ee749b6560..3d785ebb48d3ce6a0f2043afb5192d425e9b23c4 100644 (file)
@@ -1105,6 +1105,9 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
        if (!firmware_p)
                return -EINVAL;
 
+       if (!name || name[0] == '\0')
+               return -EINVAL;
+
        ret = _request_firmware_prepare(&fw, name, device);
        if (ret <= 0) /* error or already assigned */
                goto out;