[PATCH 3/5] grtc.c: Fix Dereference before null check (CID #1399840)
Ryan Long
thisisryanlong at gmail.com
Thu Feb 18 14:35:11 UTC 2021
CID 1399840: Dereference before null check in grtc_ioctl().
Closes #4252
---
bsps/shared/grlib/tmtc/grtc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bsps/shared/grlib/tmtc/grtc.c b/bsps/shared/grlib/tmtc/grtc.c
index 44e9685..e9acea4 100644
--- a/bsps/shared/grlib/tmtc/grtc.c
+++ b/bsps/shared/grlib/tmtc/grtc.c
@@ -1532,7 +1532,7 @@ static rtems_device_driver grtc_ioctl(rtems_device_major_number major, rtems_dev
struct grtc_priv *pDev;
struct drvmgr_dev *dev;
rtems_libio_ioctl_args_t *ioarg = (rtems_libio_ioctl_args_t *)arg;
- unsigned int *data = ioarg->buffer;
+ unsigned int *data;
int status,frm_len,i,ret;
struct grtc_ioc_buf_params *buf_arg;
struct grtc_ioc_config *cfg;
@@ -1556,6 +1556,8 @@ static rtems_device_driver grtc_ioctl(rtems_device_major_number major, rtems_dev
if (!ioarg)
return RTEMS_INVALID_NAME;
+ data = ioarg->buffer;
+
ioarg->ioctl_return = 0;
switch(ioarg->command) {
case GRTC_IOC_START:
--
1.8.3.1
More information about the devel
mailing list