Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4834792ybb; Tue, 14 Apr 2020 15:13:26 -0700 (PDT) X-Google-Smtp-Source: APiQypK6KePZqI+X7N5FbR+pnVRl2xK9UN4Ki46Bne5yhR3NFHkpYFfvzEGXPka0Xex7qEV9ovtD X-Received: by 2002:a17:906:f1c3:: with SMTP id gx3mr2250749ejb.25.1586902405887; Tue, 14 Apr 2020 15:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586902405; cv=none; d=google.com; s=arc-20160816; b=irxJsBCBt3NvDiN7bBkdJJ+LkphKYEN6Bj/95xjw/eGgSpO9cOAO0ne9CO0Nt0AqTS EaVd+uus2K8pmsB+tgE5Zjqdcgfue76GMOpN7X55VXPcHVMHP/PBCZlP7YoEzdqiNgi/ PB9mxrOz+dd3nSTWP2BR9y+vWQRpmLqfPZiFArecV21wDVw2g1eWOkeRsNKm7155fvtN 9uiFhdqLxVxgc/Fvxlb3k+GzwwmFextQrNiMdHsH0Ki9b5vlDXrhjVhbf6PZQK/fvJLY QbAKe/t+GXKUnJB1OOuhpmIqyAhLi70R0v6Ip/hG4IXOXvEf/pIIRgXW2r8U6SFOuhuh 2KQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=wObt/6o5gl1UwCZA1VcnmXxhxTFhCSM2Y/EC7PoOxUU=; b=VxVCS8NRskshN6U040mT3/qwelqvDn1dqXKdp0pchEfKKqBKJHYvnsQJjZpBuVQAjR Y2uA8PYeHSFHCLxXJnJbd+kCpPL4jMYhZPP56aR9lRBXuIPWH0gFCiGIjVIfvUOeCM2d U7khc21uPy4tVmkuD+oIl/QwsQO7ZRnp7NuGxPTcwriJRhr4vUxJaIT5a3zpHAZKh8M4 35S4wEaZca00x7KgxxvFRJamQHwKTgAsQp8ZjN91OyCJSLjWzgTUN5YtVFAhnVpB4GuF VQFS3QejqR9KPMyugwu6E4owuBW7QONFlwoWoosNMDMZTdim1l7JHH6mHD0iNpMsBNBy N1Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si9487787edq.380.2020.04.14.15.13.01; Tue, 14 Apr 2020 15:13:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387649AbgDMSH7 (ORCPT + 99 others); Mon, 13 Apr 2020 14:07:59 -0400 Received: from mga06.intel.com ([134.134.136.31]:12741 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387625AbgDMSHz (ORCPT ); Mon, 13 Apr 2020 14:07:55 -0400 IronPort-SDR: sKboh4/Y7aTpmZiguA/viJDnB/Onuj2n1w6U3PO1VU5GE8HWnYalFkRM+5E3XHzqUC7kTrN83K VzOFal+Sriyw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2020 11:07:55 -0700 IronPort-SDR: XnU/oKghhk93OP1z9CxvGAh0ddFLpKhKu5c6Whx6OH+EaCzbI5w/dNdxxkWxgeRao2LJ6cH+9Z drasZ0jwu20g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,378,1580803200"; d="scan'208";a="256250288" Received: from sarsteda-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.40.211]) by orsmga006.jf.intel.com with ESMTP; 13 Apr 2020 11:07:34 -0700 Date: Mon, 13 Apr 2020 21:07:32 +0300 From: Jarkko Sakkinen To: Hans de Goede Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH] tpm/tpm_tis: Free IRQ if probing fails Message-ID: <20200413180732.GA11147@linux.intel.com> References: <20200412170412.324200-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 13, 2020 at 12:04:25PM +0200, Hans de Goede wrote: > Hi Jarkko, > > On 4/12/20 7:04 PM, Jarkko Sakkinen wrote: > > Call devm_free_irq() if we have to revert to polling in order not to > > unnecessarily reserve the IRQ for the life-cycle of the driver. > > > > Cc: stable@vger.kernel.org # 4.5.x > > Reported-by: Hans de Goede > > Fixes: e3837e74a06d ("tpm_tis: Refactor the interrupt setup") > > Signed-off-by: Jarkko Sakkinen > > --- > > drivers/char/tpm/tpm_tis_core.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > > index 27c6ca031e23..ae6868e7b696 100644 > > --- a/drivers/char/tpm/tpm_tis_core.c > > +++ b/drivers/char/tpm/tpm_tis_core.c > > @@ -1062,9 +1062,12 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > > if (irq) { > > tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, > > irq); > > - if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) > > + if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { > > dev_err(&chip->dev, FW_BUG > > "TPM interrupt not working, polling instead\n"); > > + devm_free_irq(chip->dev.parent, priv->irq, > > + chip); > > + } > > My initial plan was actually to do something similar, but if the probe code > is actually ever fixed to work as intended again then this will lead to a > double free as then the IRQ-test path of tpm_tis_send() will have called > disable_interrupts() which already calls devm_free_irq(). > > You could check for chip->irq != 0 here to avoid that. > > But it all is rather messy, which is why I went with the "#if 0" approach > in my patch. I think it is right way to fix it. It is a bug independent of the issue we are experiencing. However, what you are suggesting should be done in addition. Do you have a patch in place or do you want me to refine mine? /Jarkko