[PATCH 43/44] leon, grtm: ioctl() shouldn't access pointer before validated

Daniel Hellstrom daniel at gaisler.com
Fri Mar 3 14:57:16 UTC 2017


This is a fix for a coverity warning
---
 c/src/lib/libbsp/sparc/shared/tmtc/grtm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/c/src/lib/libbsp/sparc/shared/tmtc/grtm.c b/c/src/lib/libbsp/sparc/shared/tmtc/grtm.c
index 48b4631..a1038d4 100644
--- a/c/src/lib/libbsp/sparc/shared/tmtc/grtm.c
+++ b/c/src/lib/libbsp/sparc/shared/tmtc/grtm.c
@@ -1188,7 +1188,7 @@ static rtems_device_driver grtm_ioctl(rtems_device_major_number major, rtems_dev
 	struct grtm_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;
 	struct grtm_ioc_config *cfg;
 	struct grtm_ioc_hw_status *hwregs;
@@ -1209,6 +1209,7 @@ static rtems_device_driver grtm_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 GRTM_IOC_START:
-- 
2.7.4




More information about the devel mailing list