aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-03-23 09:21:53 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2011-03-26 22:45:17 -0400
commit6d00376ad15a931d4b148e52d80abc54173e9bf5 (patch)
tree76253cde2005a2048b2e4f77c8c2d536126027b8 /drivers/crypto
parentcdc712d884cec0354d6899e7a329eee542ca2f7d (diff)
crypto: caam - ARRAY_SIZE() vs sizeof()
ARRAY_SIZE() was intended here instead of sizeof(). sizeof() is four times larger than ARRAY_SIZE(). outstr is normally 256 chars so printing garbage to it could overfill the buffer and corrupt memory. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/error.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index bd57a6825f57..7e2d54bffad6 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -73,7 +73,7 @@ static void report_ccb_status(u32 status, char *outstr)
73 73
74 report_jump_idx(status, outstr); 74 report_jump_idx(status, outstr);
75 75
76 if (cha_id < sizeof(cha_id_list)) { 76 if (cha_id < ARRAY_SIZE(cha_id_list)) {
77 SPRINTFCAT(outstr, "%s: ", cha_id_list[cha_id], 77 SPRINTFCAT(outstr, "%s: ", cha_id_list[cha_id],
78 strlen(cha_id_list[cha_id])); 78 strlen(cha_id_list[cha_id]));
79 } else { 79 } else {
@@ -81,7 +81,7 @@ static void report_ccb_status(u32 status, char *outstr)
81 cha_id, sizeof("ff")); 81 cha_id, sizeof("ff"));
82 } 82 }
83 83
84 if (err_id < sizeof(err_id_list)) { 84 if (err_id < ARRAY_SIZE(err_id_list)) {
85 SPRINTFCAT(outstr, "%s", err_id_list[err_id], 85 SPRINTFCAT(outstr, "%s", err_id_list[err_id],
86 strlen(err_id_list[err_id])); 86 strlen(err_id_list[err_id]));
87 } else { 87 } else {
@@ -198,11 +198,11 @@ static void report_deco_status(u32 status, char *outstr)
198 198
199 report_jump_idx(status, outstr); 199 report_jump_idx(status, outstr);
200 200
201 for (i = 0; i < sizeof(desc_error_list); i++) 201 for (i = 0; i < ARRAY_SIZE(desc_error_list); i++)
202 if (desc_error_list[i].value == desc_error) 202 if (desc_error_list[i].value == desc_error)
203 break; 203 break;
204 204
205 if (i != sizeof(desc_error_list) && desc_error_list[i].error_text) { 205 if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) {
206 SPRINTFCAT(outstr, "%s", desc_error_list[i].error_text, 206 SPRINTFCAT(outstr, "%s", desc_error_list[i].error_text,
207 strlen(desc_error_list[i].error_text)); 207 strlen(desc_error_list[i].error_text));
208 } else { 208 } else {