Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp981994pxx; Thu, 29 Oct 2020 21:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzMlynIpehgvA8nFIcboQjZyuRABP3R2lypvQqjWCkbkse01Ya7Lml431gGxcGfKZmIChU X-Received: by 2002:aa7:cd42:: with SMTP id v2mr277676edw.151.1604031258684; Thu, 29 Oct 2020 21:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604031258; cv=none; d=google.com; s=arc-20160816; b=zQ/PJVLJkU3Fki+PwfJy6SdkDrvTqyt9D3uA+5i3z/1diM7SOk4i5ckuTGPbUEKs8R s+oeoswEvcBRUepB8PdJQmVGa+967h8BhzfR1Z6kBkwM4VlpamUzFUFqoEOd9yKB68Js cL2FfVqvIjUPIFcMVdEeva0nTQL/qFa1Ked18S7SGlTdKxq4DrK4Ccio0ilnsxiMBfrT 21Sh8Qh1PZ8zM4WsKOvd4Hg9CVm75TO4cQjw7jPxtMUIoWneXAM71Zab5vLFf11oArrU VJFMm7Z4XPZ4nK+ab1WZCg+LE8FtJ2ytGaWkmV1Kxfhd+RxVgeD2f8YPZL8+QwCfIkNU 8qMQ== 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=j06vODX2SV/OLSFghbkcV0UlDLw5tlKFpDk9kZZyL2U=; b=Qw2d5nMV1Ss+4uowzwlKMKt5+ACMWn+IhPmkgunWYUex3cmVP/ufh1X4q5oBXTJCqt DU2UD8Puj6CwTLiq2Ns7DZtqwpYLoI+u3LQwg4GQHODeu5A5SCEeU6qVuihdrPuS/m3x +CAPRd80a/dEt16ce7f64foTWF+suOMxSh8GwAp5X0Z7s9yn0mib9LpVqE2ki1S5tuco idnUDgAUWT9+ujfGxmb09Ns/N7CqXh5m7LkpgICCeEAw9H4/jJLcAdnbXazlpmV15AhZ LOGRfglGmfgY1zSIgI4KBSh/csjALz1iHjoHIOjs+sh1mp84Fq3yaKNvxt4k91KwE4QT 9aYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=HazlPZVK; 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 v1si3665017ejd.624.2020.10.29.21.13.56; Thu, 29 Oct 2020 21:14:18 -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=HazlPZVK; 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 S1726506AbgJ3ELr (ORCPT + 99 others); Fri, 30 Oct 2020 00:11:47 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:60672 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgJ3ELN (ORCPT ); Fri, 30 Oct 2020 00:11:13 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1604031073; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=j06vODX2SV/OLSFghbkcV0UlDLw5tlKFpDk9kZZyL2U=; b=HazlPZVK2poM1H/RwGS4woNj0rYRkkngnmY2PC05r9nSdZT8nWQ2x0YznjplEgshGz0fW6IT 27Bq/CsS/n90YXG9NVx+LrK5vDyJRWpW/F8tZzNn4L7QDWhY8urroRZN7u770vb4kTxuxRba GJgNFAfylvITSEfBMicoTSNWIzg= X-Mailgun-Sending-Ip: 69.72.42.4 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-n04.prod.us-east-1.postgun.com with SMTP id 5f9b926052a6c59f171d9513 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 30 Oct 2020 04:11:12 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 0A97AC433C9; Fri, 30 Oct 2020 04:11:11 +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 D520AC433C9; Fri, 30 Oct 2020 04:11:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D520AC433C9 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 v3 12/12] bus: mhi: core: Remove MHI event ring IRQ handlers when powering down Date: Thu, 29 Oct 2020 21:10:57 -0700 Message-Id: <1604031057-32820-13-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604031057-32820-1-git-send-email-bbhatt@codeaurora.org> References: <1604031057-32820-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..a671f58 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -494,6 +494,7 @@ static void mhi_pm_disable_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