[PATCH v3 22/26] staging: most: core: check value returned by match function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux