diff options
| author | Subhani Shaik <subhanis@qca.qualcomm.com> | 2014-01-16 19:44:26 -0800 |
|---|---|---|
| committer | Prakash Dhavali <pdhavali@qca.qualcomm.com> | 2014-01-26 20:08:21 -0800 |
| commit | 4ef464ed7a20358427cfc4e0efeb98b42c2d5b7c (patch) | |
| tree | 7ed0342b618d3ff6e6a06f4680fc23c2539f1232 | |
| parent | db31b9bd9b73b976c103c0b4cb565a4cafbe050b (diff) | |
Fixes static source code analysis issues found in tools and UTILS.
This commit fixes the issues found in static source code analysis
found in UTILS and tools directory in CLD driver.
Change-Id: I89dc4fe3aedc689f2c7c8f03b703c4f8d2bbc494
CRs-fixed: 602162
| -rw-r--r-- | CORE/UTILS/PKTLOG/pktlog_internal.c | 13 | ||||
| -rw-r--r-- | tools/athdiag/athdiag.c | 19 | ||||
| -rw-r--r-- | tools/fwdebuglog/cld-fwlog-netlink.c | 8 | ||||
| -rw-r--r-- | tools/fwdebuglog/cld-fwlog-record.c | 3 |
4 files changed, 34 insertions, 9 deletions
diff --git a/CORE/UTILS/PKTLOG/pktlog_internal.c b/CORE/UTILS/PKTLOG/pktlog_internal.c index 10a99adea677..0aeae952d700 100644 --- a/CORE/UTILS/PKTLOG/pktlog_internal.c +++ b/CORE/UTILS/PKTLOG/pktlog_internal.c @@ -62,16 +62,21 @@ pktlog_getbuf_intsafe(struct ath_pktlog_arg *plarg) struct ath_pktlog_hdr *log_hdr; int32_t cur_wr_offset; char *log_ptr; - struct ath_pktlog_info *pl_info = plarg->pl_info; - u_int16_t log_type = plarg->log_type; - size_t log_size = plarg->log_size; - uint32_t flags = plarg->flags; + struct ath_pktlog_info *pl_info; + u_int16_t log_type; + size_t log_size; + uint32_t flags; if (!plarg) { printk("Invalid parg in %s\n", __func__); return; } + pl_info = plarg->pl_info; log_buf = pl_info->buf; + log_type = plarg->log_type; + log_size = plarg->log_size; + flags = plarg->flags; + if (!log_buf) { printk("Invalid log_buf in %s\n", __func__); return; diff --git a/tools/athdiag/athdiag.c b/tools/athdiag/athdiag.c index 7e0904cabdf2..17e8ead93f4d 100644 --- a/tools/athdiag/athdiag.c +++ b/tools/athdiag/athdiag.c @@ -319,6 +319,8 @@ ValidWriteOTP(int dev, A_UINT32 offset, A_UINT8 *buffer, A_UINT32 length) A_UINT8 *otp_contents; otp_contents = MALLOC(length); + if (otp_contents == NULL) + return 0; ReadTargetOTP(dev, offset, otp_contents, length); for (i=0; i<length; i++) { @@ -326,10 +328,11 @@ ValidWriteOTP(int dev, A_UINT32 offset, A_UINT8 *buffer, A_UINT32 length) fprintf(stderr, "Abort. Cannot change offset %d from 0x%02x" " to 0x%02x\n", offset+i, otp_contents[i], buffer[i]); + free(otp_contents); return 0; } } - + free(otp_contents); return 1; } @@ -404,6 +407,8 @@ DumpTargetMem(int dev, unsigned int target_idx, char *pathname) unsigned int i, address, length, remaining; buffer = (A_UINT8 *)MALLOC(MAX_BUF); + if (buffer == NULL) + return; reg_info = target_info[target_idx].reg_info; while ((reg_info->reg_start != 0) || (reg_info->reg_len != 0)) { @@ -492,7 +497,7 @@ main (int argc, char **argv) { int i; FILE * dump_fd; unsigned int address = 0, target_idx = 0, length = 0; - A_UINT32 param; + A_UINT32 param = 0; char filename[PATH_MAX], tempfn[PATH_MAX]; char pathname[PATH_MAX]; char devicename[PATH_MAX]; @@ -681,7 +686,11 @@ main (int argc, char **argv) { } buffer = (A_UINT8 *)MALLOC(MAX_BUF); - + if (buffer == NULL) { + fclose(dump_fd); + close(dev); + exit(1); + } nqprintf( "DIAG Read Target (address: 0x%x, length: %d," " filename: %s)\n", address, length, filename); @@ -757,6 +766,10 @@ main (int argc, char **argv) { } memset(&filestat, '\0', sizeof(struct stat)); buffer = (A_UINT8 *)MALLOC(MAX_BUF); + if (buffer == NULL) { + close(fd); + exit(1); + } fstat(fd, &filestat); file_length = filestat.st_size; if (file_length == 0) { diff --git a/tools/fwdebuglog/cld-fwlog-netlink.c b/tools/fwdebuglog/cld-fwlog-netlink.c index 0781441d0f52..c24226ac3462 100644 --- a/tools/fwdebuglog/cld-fwlog-netlink.c +++ b/tools/fwdebuglog/cld-fwlog-netlink.c @@ -146,7 +146,8 @@ static void cleanup(void) { if (fwlog_res == NULL) { perror("Failed to open reorder fwlog file"); - goto out; + fclose(log_out); + return; } reorder(log_out, fwlog_res); @@ -238,6 +239,11 @@ int main(int argc, char *argv[]) dest_addr.nl_groups = 0; /* unicast */ nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(RECLEN)); + if (nlh == NULL) { + fprintf(stderr, "Cannot allocate memory \n"); + close(sock_fd); + return -1; + } memset(nlh, 0, NLMSG_SPACE(RECLEN)); nlh->nlmsg_len = NLMSG_SPACE(RECLEN); nlh->nlmsg_pid = getpid(); diff --git a/tools/fwdebuglog/cld-fwlog-record.c b/tools/fwdebuglog/cld-fwlog-record.c index 138df43b3cea..8042bc9cd766 100644 --- a/tools/fwdebuglog/cld-fwlog-record.c +++ b/tools/fwdebuglog/cld-fwlog-record.c @@ -115,7 +115,8 @@ static void cleanup(void) { if (fwlog_res == NULL) { perror("Failed to open reorder fwlog file"); - goto out; + fclose(log_out); + return; } reorder(log_out, fwlog_res); |
