Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754695AbbKHHv5 (ORCPT ); Sun, 8 Nov 2015 02:51:57 -0500 Received: from mga02.intel.com ([134.134.136.20]:41653 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbbKHHvz (ORCPT ); Sun, 8 Nov 2015 02:51:55 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,261,1444719600"; d="scan'208";a="830672565" From: Jarkko Sakkinen To: Peter Huewe , Marcel Selhorst Cc: Jarkko Sakkinen , Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net (moderated list:TPM DEVICE DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] tpm: fix compat 'ppi' link handling in tpm_chip_register() Date: Sun, 8 Nov 2015 09:51:07 +0200 Message-Id: <1446969067-29016-1-git-send-email-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2030 Lines: 66 __compat_only_sysfs_link_entry_to_kobj() was unconditionally called for TPM1 chips, which caused crash on Acer C720 laptop where DSM for the ACPI object did not exist. There are two reasons for unwanted behavior: * The code did not check whether __compat_only_sysfs_link_entry_to_kobj() returned -ENOENT. This is OK. It just meanst that ppi is not available. * The code did not clean up properly. Compat link should added only after all other init is done. This patch sorts out these issues. Fixes: 9b774d5cf2db Reported-by: Jeremiah Mahler Signed-off-by: Jarkko Sakkinen Tested-by: Jeremiah Mahler --- drivers/char/tpm/tpm-chip.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index a5cdce7..45cc39a 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -226,14 +226,6 @@ int tpm_chip_register(struct tpm_chip *chip) if (rc) goto out_err; - if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { - rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, - &chip->dev.kobj, - "ppi"); - if (rc) - goto out_err; - } - /* Make the chip available. */ spin_lock(&driver_lock); list_add_tail_rcu(&chip->list, &tpm_chip_list); @@ -241,6 +233,16 @@ int tpm_chip_register(struct tpm_chip *chip) chip->flags |= TPM_CHIP_FLAG_REGISTERED; + if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { + rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, + &chip->dev.kobj, + "ppi"); + if (rc && rc != -ENOENT) { + tpm_chip_unregister(chip); + return rc; + } + } + return 0; out_err: tpm1_chip_unregister(chip); -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/