diff options
author | David S. Miller <davem@davemloft.net> | 2012-04-01 20:19:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-02 04:33:42 -0400 |
commit | 6662df33f85b87bb29f2ecad124efe7bb2c08e05 (patch) | |
tree | 13c8ac420b8d10ec3a7aa9aa7fdaa221e430c9cc /crypto | |
parent | b21dddb9dfe50ca1e205faf4b25900895494d25b (diff) |
crypto: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ablkcipher.c | 12 | ||||
-rw-r--r-- | crypto/aead.c | 12 | ||||
-rw-r--r-- | crypto/ahash.c | 6 | ||||
-rw-r--r-- | crypto/blkcipher.c | 6 | ||||
-rw-r--r-- | crypto/crypto_user.c | 22 | ||||
-rw-r--r-- | crypto/pcompress.c | 6 | ||||
-rw-r--r-- | crypto/rng.c | 6 | ||||
-rw-r--r-- | crypto/shash.c | 6 |
8 files changed, 38 insertions, 38 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index a0f768c1d9aa..c22374bf9f1e 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
@@ -397,9 +397,9 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
397 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; | 397 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; |
398 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; | 398 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; |
399 | 399 | ||
400 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | 400 | if (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER, |
401 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | 401 | sizeof(struct crypto_report_blkcipher), &rblkcipher)) |
402 | 402 | goto nla_put_failure; | |
403 | return 0; | 403 | return 0; |
404 | 404 | ||
405 | nla_put_failure: | 405 | nla_put_failure: |
@@ -478,9 +478,9 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
478 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; | 478 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; |
479 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; | 479 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; |
480 | 480 | ||
481 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | 481 | if (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER, |
482 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | 482 | sizeof(struct crypto_report_blkcipher), &rblkcipher)) |
483 | 483 | goto nla_put_failure; | |
484 | return 0; | 484 | return 0; |
485 | 485 | ||
486 | nla_put_failure: | 486 | nla_put_failure: |
diff --git a/crypto/aead.c b/crypto/aead.c index 04add3dca6fe..c772b9c79ee7 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
@@ -125,9 +125,9 @@ static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
125 | raead.maxauthsize = aead->maxauthsize; | 125 | raead.maxauthsize = aead->maxauthsize; |
126 | raead.ivsize = aead->ivsize; | 126 | raead.ivsize = aead->ivsize; |
127 | 127 | ||
128 | NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD, | 128 | if (nla_put(skb, CRYPTOCFGA_REPORT_AEAD, |
129 | sizeof(struct crypto_report_aead), &raead); | 129 | sizeof(struct crypto_report_aead), &raead)) |
130 | 130 | goto nla_put_failure; | |
131 | return 0; | 131 | return 0; |
132 | 132 | ||
133 | nla_put_failure: | 133 | nla_put_failure: |
@@ -210,9 +210,9 @@ static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
210 | raead.maxauthsize = aead->maxauthsize; | 210 | raead.maxauthsize = aead->maxauthsize; |
211 | raead.ivsize = aead->ivsize; | 211 | raead.ivsize = aead->ivsize; |
212 | 212 | ||
213 | NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD, | 213 | if (nla_put(skb, CRYPTOCFGA_REPORT_AEAD, |
214 | sizeof(struct crypto_report_aead), &raead); | 214 | sizeof(struct crypto_report_aead), &raead)) |
215 | 215 | goto nla_put_failure; | |
216 | return 0; | 216 | return 0; |
217 | 217 | ||
218 | nla_put_failure: | 218 | nla_put_failure: |
diff --git a/crypto/ahash.c b/crypto/ahash.c index 33bc9b62e9ae..3887856c2dd6 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c | |||
@@ -409,9 +409,9 @@ static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
409 | rhash.blocksize = alg->cra_blocksize; | 409 | rhash.blocksize = alg->cra_blocksize; |
410 | rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize; | 410 | rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize; |
411 | 411 | ||
412 | NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH, | 412 | if (nla_put(skb, CRYPTOCFGA_REPORT_HASH, |
413 | sizeof(struct crypto_report_hash), &rhash); | 413 | sizeof(struct crypto_report_hash), &rhash)) |
414 | 414 | goto nla_put_failure; | |
415 | return 0; | 415 | return 0; |
416 | 416 | ||
417 | nla_put_failure: | 417 | nla_put_failure: |
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 4dd80c725498..a8d85a1d670e 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -508,9 +508,9 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
508 | rblkcipher.max_keysize = alg->cra_blkcipher.max_keysize; | 508 | rblkcipher.max_keysize = alg->cra_blkcipher.max_keysize; |
509 | rblkcipher.ivsize = alg->cra_blkcipher.ivsize; | 509 | rblkcipher.ivsize = alg->cra_blkcipher.ivsize; |
510 | 510 | ||
511 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | 511 | if (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER, |
512 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | 512 | sizeof(struct crypto_report_blkcipher), &rblkcipher)) |
513 | 513 | goto nla_put_failure; | |
514 | return 0; | 514 | return 0; |
515 | 515 | ||
516 | nla_put_failure: | 516 | nla_put_failure: |
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index f76e42bcc6e7..84a5ac71ecb4 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c | |||
@@ -77,9 +77,9 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg) | |||
77 | rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; | 77 | rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; |
78 | rcipher.max_keysize = alg->cra_cipher.cia_max_keysize; | 78 | rcipher.max_keysize = alg->cra_cipher.cia_max_keysize; |
79 | 79 | ||
80 | NLA_PUT(skb, CRYPTOCFGA_REPORT_CIPHER, | 80 | if (nla_put(skb, CRYPTOCFGA_REPORT_CIPHER, |
81 | sizeof(struct crypto_report_cipher), &rcipher); | 81 | sizeof(struct crypto_report_cipher), &rcipher)) |
82 | 82 | goto nla_put_failure; | |
83 | return 0; | 83 | return 0; |
84 | 84 | ||
85 | nla_put_failure: | 85 | nla_put_failure: |
@@ -92,9 +92,9 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg) | |||
92 | 92 | ||
93 | snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression"); | 93 | snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression"); |
94 | 94 | ||
95 | NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS, | 95 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, |
96 | sizeof(struct crypto_report_comp), &rcomp); | 96 | sizeof(struct crypto_report_comp), &rcomp)) |
97 | 97 | goto nla_put_failure; | |
98 | return 0; | 98 | return 0; |
99 | 99 | ||
100 | nla_put_failure: | 100 | nla_put_failure: |
@@ -113,16 +113,16 @@ static int crypto_report_one(struct crypto_alg *alg, | |||
113 | ualg->cru_flags = alg->cra_flags; | 113 | ualg->cru_flags = alg->cra_flags; |
114 | ualg->cru_refcnt = atomic_read(&alg->cra_refcnt); | 114 | ualg->cru_refcnt = atomic_read(&alg->cra_refcnt); |
115 | 115 | ||
116 | NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority); | 116 | if (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority)) |
117 | 117 | goto nla_put_failure; | |
118 | if (alg->cra_flags & CRYPTO_ALG_LARVAL) { | 118 | if (alg->cra_flags & CRYPTO_ALG_LARVAL) { |
119 | struct crypto_report_larval rl; | 119 | struct crypto_report_larval rl; |
120 | 120 | ||
121 | snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval"); | 121 | snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval"); |
122 | 122 | ||
123 | NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL, | 123 | if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, |
124 | sizeof(struct crypto_report_larval), &rl); | 124 | sizeof(struct crypto_report_larval), &rl)) |
125 | 125 | goto nla_put_failure; | |
126 | goto out; | 126 | goto out; |
127 | } | 127 | } |
128 | 128 | ||
diff --git a/crypto/pcompress.c b/crypto/pcompress.c index 2e458e5482d0..04e083ff5373 100644 --- a/crypto/pcompress.c +++ b/crypto/pcompress.c | |||
@@ -55,9 +55,9 @@ static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
55 | 55 | ||
56 | snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp"); | 56 | snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp"); |
57 | 57 | ||
58 | NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS, | 58 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, |
59 | sizeof(struct crypto_report_comp), &rpcomp); | 59 | sizeof(struct crypto_report_comp), &rpcomp)) |
60 | 60 | goto nla_put_failure; | |
61 | return 0; | 61 | return 0; |
62 | 62 | ||
63 | nla_put_failure: | 63 | nla_put_failure: |
diff --git a/crypto/rng.c b/crypto/rng.c index 64f864fa8043..f3b7894dec00 100644 --- a/crypto/rng.c +++ b/crypto/rng.c | |||
@@ -69,9 +69,9 @@ static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
69 | 69 | ||
70 | rrng.seedsize = alg->cra_rng.seedsize; | 70 | rrng.seedsize = alg->cra_rng.seedsize; |
71 | 71 | ||
72 | NLA_PUT(skb, CRYPTOCFGA_REPORT_RNG, | 72 | if (nla_put(skb, CRYPTOCFGA_REPORT_RNG, |
73 | sizeof(struct crypto_report_rng), &rrng); | 73 | sizeof(struct crypto_report_rng), &rrng)) |
74 | 74 | goto nla_put_failure; | |
75 | return 0; | 75 | return 0; |
76 | 76 | ||
77 | nla_put_failure: | 77 | nla_put_failure: |
diff --git a/crypto/shash.c b/crypto/shash.c index 21fc12e2378f..32067f47e6c7 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -534,9 +534,9 @@ static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
534 | rhash.blocksize = alg->cra_blocksize; | 534 | rhash.blocksize = alg->cra_blocksize; |
535 | rhash.digestsize = salg->digestsize; | 535 | rhash.digestsize = salg->digestsize; |
536 | 536 | ||
537 | NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH, | 537 | if (nla_put(skb, CRYPTOCFGA_REPORT_HASH, |
538 | sizeof(struct crypto_report_hash), &rhash); | 538 | sizeof(struct crypto_report_hash), &rhash)) |
539 | 539 | goto nla_put_failure; | |
540 | return 0; | 540 | return 0; |
541 | 541 | ||
542 | nla_put_failure: | 542 | nla_put_failure: |