Skip to content

Commit

Permalink
[PATCH] tpm: large stack objects
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kylene Hall authored and Linus Torvalds committed Jun 24, 2005
1 parent 5b44bd5 commit 2df7111
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static const u8 readpubek[] = {

static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
{
u8 data[READ_PUBEK_RESULT_SIZE];
u8 *data;
ssize_t len;
__be32 *native_val;
int i;
Expand All @@ -266,12 +266,18 @@ static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, cha
if (chip == NULL)
return -ENODEV;

data = kmalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL);
if (!data)
return -ENOMEM;

memcpy(data, readpubek, sizeof(readpubek));
memset(data + sizeof(readpubek), 0, 20); /* zero nonce */

if ((len = tpm_transmit(chip, data, sizeof(data))) <
READ_PUBEK_RESULT_SIZE)
return len;
if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) <
READ_PUBEK_RESULT_SIZE) {
rc = len;
goto out;
}

/*
ignore header 10 bytes
Expand Down Expand Up @@ -304,7 +310,10 @@ static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, cha
if ((i + 1) % 16 == 0)
str += sprintf(str, "\n");
}
return str - buf;
rc = str - buf;
out:
kfree(data);
return rc;
}

static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL);
Expand All @@ -330,7 +339,7 @@ static const u8 cap_manufacturer[] = {

static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
{
u8 data[READ_PUBEK_RESULT_SIZE];
u8 data[sizeof(cap_manufacturer)];
ssize_t len;
char *str = buf;

Expand Down

0 comments on commit 2df7111

Please sign in to comment.