TPM: integrity fix
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>
Thu, 5 Feb 2009 15:06:30 +0000 (13:06 -0200)
committerJames Morris <jmorris@namei.org>
Thu, 5 Feb 2009 22:06:43 +0000 (09:06 +1100)
Fix to function which is called by IMA, now tpm_chip_find_get() considers the case in which the machine doesn't have a TPM or, if it has, its TPM isn't enabled.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
drivers/char/tpm/tpm.c

index 62a5682578cace94bd6dcca7306a0a5a47df9a4a..ccdd828adcef2711e2ed91a7c52f38b1a6dca844 100644 (file)
@@ -666,18 +666,20 @@ EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  */
 static struct tpm_chip *tpm_chip_find_get(int chip_num)
 {
-       struct tpm_chip *pos;
+       struct tpm_chip *pos, *chip = NULL;
 
        rcu_read_lock();
        list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
                if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
                        continue;
 
-               if (try_module_get(pos->dev->driver->owner))
+               if (try_module_get(pos->dev->driver->owner)) {
+                       chip = pos;
                        break;
+               }
        }
        rcu_read_unlock();
-       return pos;
+       return chip;
 }
 
 #define TPM_ORDINAL_PCRREAD cpu_to_be32(21)