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.gr...@microchip.com>
---
v2: fix patch numeration
v3: - add cover letter
    - create patches with -M switch to make file movement visible

 drivers/staging/most/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 7cbef80..c061e67 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -723,6 +723,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);
@@ -766,6 +768,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;
-- 
1.9.1

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to