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>
Thu, 30 Oct 2014 16:35:10 +0000 (09:35 -0700)
commit 471b095dfe0d693a8d624cbc716d1ee4d74eb437 upstream.

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>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/firmware_class.c

index 01e21037d8feb5c04e6aedee608e9cdedc0d87bd..00a5656765835d81b518aecbdfb9ebfe17ffc39a 100644 (file)
@@ -1021,6 +1021,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;