aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorKylene Hall <kjhall@us.ibm.com>2005-06-24 01:01:54 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:25 -0400
commit2df7111fc6b0e050b06123379821ece2f8dd5bbc (patch)
tree76ef3f3bcfdd808101474143c2d174fcb64d5b90 /drivers/char/tpm
parent5b44bd58063f7839f42a4047843e93e1fbf73cda (diff)
[PATCH] tpm: large stack objects
Remove some large objects be declared on the the stack. Signed-off-by: Kylene Hall <kjhall@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 7b1f67d9f301..2035c15ffcce 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -255,7 +255,7 @@ static const u8 readpubek[] = {
255 255
256static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf) 256static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
257{ 257{
258 u8 data[READ_PUBEK_RESULT_SIZE]; 258 u8 *data;
259 ssize_t len; 259 ssize_t len;
260 __be32 *native_val; 260 __be32 *native_val;
261 int i; 261 int i;
@@ -266,12 +266,18 @@ static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, cha
266 if (chip == NULL) 266 if (chip == NULL)
267 return -ENODEV; 267 return -ENODEV;
268 268
269 data = kmalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL);
270 if (!data)
271 return -ENOMEM;
272
269 memcpy(data, readpubek, sizeof(readpubek)); 273 memcpy(data, readpubek, sizeof(readpubek));
270 memset(data + sizeof(readpubek), 0, 20); /* zero nonce */ 274 memset(data + sizeof(readpubek), 0, 20); /* zero nonce */
271 275
272 if ((len = tpm_transmit(chip, data, sizeof(data))) < 276 if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) <
273 READ_PUBEK_RESULT_SIZE) 277 READ_PUBEK_RESULT_SIZE) {
274 return len; 278 rc = len;
279 goto out;
280 }
275 281
276 /* 282 /*
277 ignore header 10 bytes 283 ignore header 10 bytes
@@ -304,7 +310,10 @@ static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, cha
304 if ((i + 1) % 16 == 0) 310 if ((i + 1) % 16 == 0)
305 str += sprintf(str, "\n"); 311 str += sprintf(str, "\n");
306 } 312 }
307 return str - buf; 313 rc = str - buf;
314out:
315 kfree(data);
316 return rc;
308} 317}
309 318
310static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL); 319static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL);
@@ -330,7 +339,7 @@ static const u8 cap_manufacturer[] = {
330 339
331static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf) 340static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
332{ 341{
333 u8 data[READ_PUBEK_RESULT_SIZE]; 342 u8 data[sizeof(cap_manufacturer)];
334 ssize_t len; 343 ssize_t len;
335 char *str = buf; 344 char *str = buf;
336 345