فهرست منبع

dev/portal: add checks on oflag

It does not make sense to open portal without a flag. One should open a
portal with RT_DEVICE_OFLAG_RDWR in most cases.
Grissiom 11 سال پیش
والد
کامیت
824261d3bc
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      components/drivers/src/portal.c

+ 3 - 0
components/drivers/src/portal.c

@@ -53,6 +53,9 @@ static rt_err_t _portal_open(rt_device_t dev, rt_uint16_t oflag)
 
     RT_ASSERT(dev);
 
+    if (!oflag)
+        return -RT_ERROR;
+
     portal = (struct rt_portal_device*)dev;
 
     if (oflag & RT_DEVICE_OFLAG_RDONLY)