diff options
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index aa899cec6b3f..e70d13defde4 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -1187,11 +1187,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1187 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1187 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1188 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); | 1188 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); |
1189 | 1189 | ||
1190 | if (chip == NULL || devname == NULL) { | 1190 | if (chip == NULL || devname == NULL) |
1191 | kfree(chip); | 1191 | goto out_free; |
1192 | kfree(devname); | ||
1193 | return NULL; | ||
1194 | } | ||
1195 | 1192 | ||
1196 | mutex_init(&chip->buffer_mutex); | 1193 | mutex_init(&chip->buffer_mutex); |
1197 | mutex_init(&chip->tpm_mutex); | 1194 | mutex_init(&chip->tpm_mutex); |
@@ -1208,8 +1205,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1208 | 1205 | ||
1209 | if (chip->dev_num >= TPM_NUM_DEVICES) { | 1206 | if (chip->dev_num >= TPM_NUM_DEVICES) { |
1210 | dev_err(dev, "No available tpm device numbers\n"); | 1207 | dev_err(dev, "No available tpm device numbers\n"); |
1211 | kfree(chip); | 1208 | goto out_free; |
1212 | return NULL; | ||
1213 | } else if (chip->dev_num == 0) | 1209 | } else if (chip->dev_num == 0) |
1214 | chip->vendor.miscdev.minor = TPM_MINOR; | 1210 | chip->vendor.miscdev.minor = TPM_MINOR; |
1215 | else | 1211 | else |
@@ -1250,6 +1246,11 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1250 | spin_unlock(&driver_lock); | 1246 | spin_unlock(&driver_lock); |
1251 | 1247 | ||
1252 | return chip; | 1248 | return chip; |
1249 | |||
1250 | out_free: | ||
1251 | kfree(chip); | ||
1252 | kfree(devname); | ||
1253 | return NULL; | ||
1253 | } | 1254 | } |
1254 | EXPORT_SYMBOL_GPL(tpm_register_hardware); | 1255 | EXPORT_SYMBOL_GPL(tpm_register_hardware); |
1255 | 1256 | ||