diff options
-rw-r--r-- | drivers/char/tpm/tpm.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index e5a254a434f8..ef991cd8c024 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -942,12 +942,12 @@ int tpm_release(struct inode *inode, struct file *file) | |||
942 | { | 942 | { |
943 | struct tpm_chip *chip = file->private_data; | 943 | struct tpm_chip *chip = file->private_data; |
944 | 944 | ||
945 | flush_scheduled_work(); | ||
945 | spin_lock(&driver_lock); | 946 | spin_lock(&driver_lock); |
946 | file->private_data = NULL; | 947 | file->private_data = NULL; |
947 | chip->num_opens--; | ||
948 | del_singleshot_timer_sync(&chip->user_read_timer); | 948 | del_singleshot_timer_sync(&chip->user_read_timer); |
949 | flush_scheduled_work(); | ||
950 | atomic_set(&chip->data_pending, 0); | 949 | atomic_set(&chip->data_pending, 0); |
950 | chip->num_opens--; | ||
951 | put_device(chip->dev); | 951 | put_device(chip->dev); |
952 | kfree(chip->data_buffer); | 952 | kfree(chip->data_buffer); |
953 | spin_unlock(&driver_lock); | 953 | spin_unlock(&driver_lock); |
@@ -1097,8 +1097,13 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend | |||
1097 | 1097 | ||
1098 | /* Driver specific per-device data */ | 1098 | /* Driver specific per-device data */ |
1099 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1099 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1100 | if (chip == NULL) | 1100 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); |
1101 | |||
1102 | if (chip == NULL || devname == NULL) { | ||
1103 | kfree(chip); | ||
1104 | kfree(devname); | ||
1101 | return NULL; | 1105 | return NULL; |
1106 | } | ||
1102 | 1107 | ||
1103 | init_MUTEX(&chip->buffer_mutex); | 1108 | init_MUTEX(&chip->buffer_mutex); |
1104 | init_MUTEX(&chip->tpm_mutex); | 1109 | init_MUTEX(&chip->tpm_mutex); |
@@ -1124,7 +1129,6 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend | |||
1124 | 1129 | ||
1125 | set_bit(chip->dev_num, dev_mask); | 1130 | set_bit(chip->dev_num, dev_mask); |
1126 | 1131 | ||
1127 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); | ||
1128 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); | 1132 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); |
1129 | chip->vendor.miscdev.name = devname; | 1133 | chip->vendor.miscdev.name = devname; |
1130 | 1134 | ||