[PATCH 2/5] b1553rt.c: Fix Deference before null check (CID #1399830)

Ryan Long thisisryanlong at gmail.com
Thu Feb 18 14:35:10 UTC 2021


CID 1399830: Dereference before null check in rt_control().

Closes #4251
---
 bsps/shared/grlib/1553/b1553rt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/1553/b1553rt.c b/bsps/shared/grlib/1553/b1553rt.c
index d7257e4..df72ada 100644
--- a/bsps/shared/grlib/1553/b1553rt.c
+++ b/bsps/shared/grlib/1553/b1553rt.c
@@ -619,7 +619,7 @@ static rtems_device_driver rt_write(rtems_device_major_number major, rtems_devic
 static rtems_device_driver rt_control(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
 {
     rtems_libio_ioctl_args_t *ioarg = (rtems_libio_ioctl_args_t *) arg;
-    unsigned int *data = ioarg->buffer;
+    unsigned int *data;
 
     rt_priv *rt;
     struct drvmgr_dev *dev;
@@ -636,6 +636,8 @@ static rtems_device_driver rt_control(rtems_device_major_number major, rtems_dev
         return RTEMS_INVALID_NAME;
     }
 
+    data = ioarg->buffer;
+
     ioarg->ioctl_return = 0;
     switch (ioarg->command) {
 
-- 
1.8.3.1



More information about the devel mailing list