فهرست منبع

staging: most: core: check value returned by match function

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>
Christian Gromm 7 سال پیش
والد
کامیت
3ba5515bf4
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      drivers/staging/most/core.c

+ 4 - 0
drivers/staging/most/core.c

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