Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp923497pxx; Thu, 29 Oct 2020 18:54:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG104USTmSHXDU3S7KzuEuar7Bo/BVcqFuQiGC+aX/z3PWsMI+9XD3du3S+57DrpVDN8A1 X-Received: by 2002:a50:8125:: with SMTP id 34mr7406356edc.39.1604022854634; Thu, 29 Oct 2020 18:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604022854; cv=none; d=google.com; s=arc-20160816; b=HvPElBTFyn38rBfMKeKb5g2PD6oZ2/0cVLbk34jmhSR4zxg1LKPB8VGIQi/tJ5js5V 3vtiI5XQpiPrnuf3Sz92yY3xm86viQtMOJukEDN1lzkBg97oa7w0LPNtdLlLpcQUqTuR KzZblZfslbalof2jzdvyXV3PRQL+5U1T35RrNlUtT1j1lQPNeJvdav0bqh91gudAV5y7 KBu098okAz00SgnkEEP+ETR3PmnSGfN7ppuCgtDOsqpWa4eXfLR0RHvKvg21lLM9ewXe +zc6FAOBAgEGnlfFr4wVuWWPAsS0HR2MX08b1bQRebOXeioG2RcfGK0D651q0yPRfaph /WuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=muClZ3aEgtW2SVMTa7yNNtr5APzEcgr+2RBahZX568o=; b=q8ZRX5WNuzE6fYNcAFJrfgIDA/6OrUWFZLhDtq2pnHoafYkiIGXOgpTZnQmzh0DxsY YVeTWU+2KyjepuYs+XHF4me995ZbYVr2S0mTfT3574gYGtjzDuvNrSEQmYIC3a/Qcm0r e+gCRZLap0CjxUorkZRkSrobSsKB8+G22oZeE7EpMhZPspH9UUWPqImdoUtDfXAwcg7x LLIB17rUPyIl7CWb88rJLSmb/bmcWH1EEstKfebEcmBFa60Ei09u/DzFT/1OLx+HxV2J zx4+X1ZznBFNZG1cZuqGtaUTPuTJVepF+tAIw+u6TRG/XM4RAmwxMxD+JEvIvgWyCCs6 X2cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=O1kia20W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay17si3375702ejb.281.2020.10.29.18.53.52; Thu, 29 Oct 2020 18:54:14 -0700 (PDT) Received-SPF: pass (google.com: 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=@mg.codeaurora.org header.s=smtp header.b=O1kia20W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbgJ3BwY (ORCPT + 99 others); Thu, 29 Oct 2020 21:52:24 -0400 Received: from z5.mailgun.us ([104.130.96.5]:37959 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbgJ3BwS (ORCPT ); Thu, 29 Oct 2020 21:52:18 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1604022738; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=muClZ3aEgtW2SVMTa7yNNtr5APzEcgr+2RBahZX568o=; b=O1kia20WaMvD+zABsuBaO+KChp8vbMH3JWwZGuEhXrqTuqQhXyKrY+j5Usnnd6q9yasYtkLm y9lJ10RQvG67cKozF85LkDDHHxloJfg8R07TQZe2hkungblGuIzY7fEU8rws2kmBFYGicuqS OM4ahZSC/t3xfi3gIfLxFpSq3V8= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 5f9b71d252a6c59f17fb8740 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 30 Oct 2020 01:52:18 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 43A25C43387; Fri, 30 Oct 2020 01:52:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from malabar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bbhatt) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7EAE6C43382; Fri, 30 Oct 2020 01:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7EAE6C43382 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=bbhatt@codeaurora.org From: Bhaumik Bhatt To: manivannan.sadhasivam@linaro.org Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Bhaumik Bhatt Subject: [PATCH v2 12/12] bus: mhi: core: Remove MHI event ring IRQ handlers when powering down Date: Thu, 29 Oct 2020 18:52:03 -0700 Message-Id: <1604022723-34578-13-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604022723-34578-1-git-send-email-bbhatt@codeaurora.org> References: <1604022723-34578-1-git-send-email-bbhatt@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While powering down, the device may or may not acknowledge an MHI RESET issued by host for a graceful shutdown scenario and end up sending an incoming data packet after tasklets have been killed. If a rogue device sends this interrupt for a data transfer event ring update, it can result in a tasklet getting scheduled while a clean up is ongoing or has completed and cause access to freed memory leading to a NULL pointer exception. Remove the interrupt handlers for MHI event rings early on to avoid this scenario. Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/pm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index ffbf6f5..28e2b87 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -627,6 +627,7 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl) for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { if (mhi_event->offload_ev) continue; + free_irq(mhi_cntrl->irq[mhi_event->irq], mhi_event); tasklet_kill(&mhi_event->task); } @@ -1164,7 +1165,7 @@ void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) /* Wait for shutdown to complete */ flush_work(&mhi_cntrl->st_worker); - mhi_deinit_free_irq(mhi_cntrl); + free_irq(mhi_cntrl->irq[0], mhi_cntrl); if (!mhi_cntrl->pre_init) { /* Free all allocated resources */ -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project