]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: most: core: check value returned by match function
authorChristian Gromm <christian.gromm@microchip.com>
Tue, 21 Nov 2017 14:05:17 +0000 (15:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Nov 2017 08:20:37 +0000 (09:20 +0100)
This patch adds a check for the pointer returned by the function
match_component. It is needed to prevent a NULL pointer dereference in
case the provided component name does not match any list entry.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/core.c

index 839e6cf4fbc0b01fb54055f925c4779a22b6c445..6e7dcb5999bd0b0e2244f8e5023787157277b61e 100644 (file)
@@ -711,6 +711,8 @@ static ssize_t add_link_store(struct device_driver *drv,
        if (ret)
                return ret;
        comp = match_component(comp_name);
+       if (!comp)
+               return -ENODEV;
        if (!comp_param || *comp_param == 0) {
                snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev,
                         mdev_ch);
@@ -754,6 +756,8 @@ static ssize_t remove_link_store(struct device_driver *drv,
        if (ret)
                return ret;
        comp = match_component(comp_name);
+       if (!comp)
+               return -ENODEV;
        c = get_channel(mdev, mdev_ch);
        if (!c)
                return -ENODEV;