diff options
| author | Subhani Shaik <subhanis@qca.qualcomm.com> | 2014-03-30 18:00:36 -0700 |
|---|---|---|
| committer | Akash Patel <c_akashp@qca.qualcomm.com> | 2014-04-01 21:21:43 -0700 |
| commit | 584aab45317ef53408cd66c60fe1844a8a13a93c (patch) | |
| tree | 22fc3e0507745e30e660a2014823b31ba1475cdc | |
| parent | f389f68e30c111507e2c517379ae2feb06e1bfab (diff) | |
Static analyzer P1 issues.
The target index can be greater than 2 incase of dump and this
will cause garbage access. Checking the index access before
retriving the value.
Change-Id: Idccbe38930e32e5e3e95a1d5a658958fae49974f
CRs-fixed: 640666
| -rw-r--r-- | tools/athdiag/athdiag.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/athdiag/athdiag.c b/tools/athdiag/athdiag.c index a3b7ef3bc9b7..bbbb0165be8f 100644 --- a/tools/athdiag/athdiag.c +++ b/tools/athdiag/athdiag.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 The Linux Foundation. All rights reserved. + * Copyright (c) "2012,2014" The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -135,6 +135,9 @@ static const struct ath_target_reg_info reg_ar6320_v1[] = { #define INVALID_TARGET_INDEX 0xffff +#define MIN_TARGET_INDEX 0 +#define MAX_TARGET_INDEX 2 + struct ath_target_info { const char *name; const struct ath_target_reg_info *reg_info; @@ -407,11 +410,14 @@ DumpTargetMem(int dev, unsigned int target_idx, char *pathname) A_UINT8 *buffer; unsigned int i, address, length, remaining; + if ((target_idx < MIN_TARGET_INDEX) || (target_idx >= MAX_TARGET_INDEX)) + return; + buffer = (A_UINT8 *)MALLOC(MAX_BUF); if (buffer == NULL) return; - reg_info = target_info[target_idx].reg_info; + reg_info = target_info[target_idx].reg_info; while ((reg_info->reg_start != 0) || (reg_info->reg_len != 0)) { memset(filename, 0, sizeof(filename)); snprintf(filename, sizeof(filename), "%s%s", pathname, |
