[PATCH v3 22/26] staging: most: core: check value returned by match function
Christian Gromm
christian.gromm at microchip.com
Mon Oct 16 08:46:29 UTC 2017
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 at 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
More information about the devel
mailing list