Private
Public Access
2
0

coverity: Fix issues found by coverity scan

* Fix a few resource leaks in error conditions
* Makes strtol() calls safer in pwm module
* Make sure buffer is terminated after read() in aio

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-10-03 22:50:18 +01:00
parent 4e5ec299ed
commit 2b5e38b40c
6 changed files with 42 additions and 11 deletions

View File

@@ -55,8 +55,10 @@ mraa_i2c_init_raw(unsigned int bus)
return NULL;
}
mraa_i2c_context dev = (mraa_i2c_context) malloc(sizeof(struct _i2c));
if (dev == NULL)
if (dev == NULL) {
syslog(LOG_CRIT, "Failed to allocate memory for context");
return NULL;
}
char filepath[32];
snprintf(filepath, 32, "/dev/i2c-%u", bus);
@@ -96,9 +98,6 @@ uint8_t
mraa_i2c_read_byte(mraa_i2c_context dev)
{
uint8_t byte = i2c_smbus_read_byte(dev->fh);
if (byte < 0) {
return -1;
}
return byte;
}