Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4479639ybb; Tue, 14 Apr 2020 08:07:09 -0700 (PDT) X-Google-Smtp-Source: APiQypL2wMPClvoL8bms48DQl+y0nG47wUASLme2C3ZHE8cbhbl+9fY5nZOo4znjr7Q0XfgFtl6U X-Received: by 2002:a17:906:614a:: with SMTP id p10mr607077ejl.88.1586876829568; Tue, 14 Apr 2020 08:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586876829; cv=none; d=google.com; s=arc-20160816; b=Tw/hb6B4OICTIY9as701ewAjfFROLMggu7pNMDTQfSp8fgSLQBXIr4ysx/IUNwJdNl josA9R7i39Z0jmc640oNjpl0MYsMRDFbMU0z6QFlJ6BVroT7k4lxPhfuxQ3+vtdz3A8n hJJROZA2sW76eS+vDOwIYp7jVtqCLjOtppb0U1jS96qprcZzBhH6MGIOkXqPfH5dKAcn HRdyvLsRQumKnGlrdr94C3CUg0wWhCDNWPsUZw2LAAIbEiITP9n+Z3mveerQsITPDnVT uRwkwmnA2Ar24ZQk30W6VP26D05GFtEU+LipJKLV1ej3NuCY9uHMazUup1ZbROWg2P3X Q15Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=b37d0Kofi4/XRxv8UfpXOdTiWurzTmejZQ30rVyez0k=; b=qki/y2LYr8SRo16mPOCIOCOULZ0Q+FMST1+0jQqQJItcGxk9NBMA3U+NvHBu2sPhGG cS+a19mRp0p4Z0EsvSMB+uNeE0O+ULSHtunU3TGKZ3Gldb1kBCetgSnaCHUnkPluvnvY gL44ZqD98kPBYr1J0B9SUxc/APMltQ1Ehw1vil59h1csagfMbmeHYHhRM7aldXXYRVND cq7n/frP9izBR7Ka3YDz08nfhWxucaGrFZpreXy/J9IEWNpYp7t4Jfc/hYvBkoWHSGip ZIPoYYGRrE4TLCuw0mdVav5YdR2+joJEyc+ytPAKEJM2Eq97d8FRe/DNSZM9aHTFtKGJ k3iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GITeOYGX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si2661656ejo.516.2020.04.14.08.06.41; Tue, 14 Apr 2020 08:07:07 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GITeOYGX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436798AbgDNI1A (ORCPT + 99 others); Tue, 14 Apr 2020 04:27:00 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54222 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2436781AbgDNI0k (ORCPT ); Tue, 14 Apr 2020 04:26:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586852798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b37d0Kofi4/XRxv8UfpXOdTiWurzTmejZQ30rVyez0k=; b=GITeOYGXVWfEV2rb6jI+04vdqL04akUPwXjlfwcmESqBE1WplUTIjMt6mOCWyvBzGgCrct uL99TxZNO8jooIJXRvEexJCx+ePQ6kEQtIBaKbnYxI/+2Xn6oyNaaN/LlFsx5XuErnk1Y0 YuUD4Ycjeu8QdKXLAexOKPhTTkZhE3Q= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-Lbn6NtKjPSK6tEeoc02sAA-1; Tue, 14 Apr 2020 04:26:36 -0400 X-MC-Unique: Lbn6NtKjPSK6tEeoc02sAA-1 Received: by mail-wm1-f69.google.com with SMTP id f17so3477913wmm.5 for ; Tue, 14 Apr 2020 01:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=b37d0Kofi4/XRxv8UfpXOdTiWurzTmejZQ30rVyez0k=; b=oTr4XT/meHcL0vCaCzMqce6pAEN4XZPIcJjvMTfmFNoPXkzwys6Fgc8JLYAQRsGLB/ 5L28COvsGxHAvFdur9qPz5ovNx+cR3tcoVblWnE27dm7TU4qVQvw9vaDg2I4v4SzL/BO rc2ksmhiOVErbPQEss4PmAmtE7EVB2r+errNB0U+yHXIGZe/3AYCXSLaulpu2xJw3VGx t4LMj6hi5Dyy1Olrp/FAdA6ppKZHNB/tSBjJY0dgDhLaxQSe0+tGaVvvgy7gQNBqSH9p lL3ptwNRGnVTl42FGNvFcbZxmzKud0N/TBVO9wSpYrH6XlQa8KoHxCgap7UvpCPwe8PL B77A== X-Gm-Message-State: AGi0Pubberdf9/hxu0HpDSVki22nyCucQnZ8K0/XothTYEb6O4Vg0cz2 yQioLc+Gb4QTc1LSiui0uVb6nNA2JME/e07Sk7pnD2ll37k9zX9vysjJ0uIhsaMEPTdjCZfb8ML Z0f5T4Tf5Un2IQ2q7wUJQb1VZ X-Received: by 2002:a7b:c401:: with SMTP id k1mr21977055wmi.152.1586852795048; Tue, 14 Apr 2020 01:26:35 -0700 (PDT) X-Received: by 2002:a7b:c401:: with SMTP id k1mr21976977wmi.152.1586852793854; Tue, 14 Apr 2020 01:26:33 -0700 (PDT) Received: from x1.localdomain (2001-1c00-0c0c-fe00-d2ea-f29d-118b-24dc.cable.dynamic.v6.ziggo.nl. [2001:1c00:c0c:fe00:d2ea:f29d:118b:24dc]) by smtp.gmail.com with ESMTPSA id y7sm18913048wmb.43.2020.04.14.01.26.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Apr 2020 01:26:33 -0700 (PDT) Subject: Re: [PATCH] tpm/tpm_tis: Free IRQ if probing fails To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list References: <20200412170412.324200-1-jarkko.sakkinen@linux.intel.com> <20200413180732.GA11147@linux.intel.com> <7df7f8bd-c65e-1435-7e82-b9f4ecd729de@redhat.com> <20200414071349.GA8403@linux.intel.com> From: Hans de Goede Message-ID: Date: Tue, 14 Apr 2020 10:26:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200414071349.GA8403@linux.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 4/14/20 9:13 AM, Jarkko Sakkinen wrote: > On Mon, Apr 13, 2020 at 08:11:15PM +0200, Hans de Goede wrote: >> Hi, >> >> On 4/13/20 8:07 PM, Jarkko Sakkinen wrote: >>> 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. Erm in case you haven't figured it out yet this should be priv->irq != 0, sorry. >>>> >>>> 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? >> >> I do not have a patch ready for this, if you can refine yours that would >> be great. > > Thanks! Just wanted to confirm. And thank you for working on a (temporary?) fix for this. Regards, Hans