Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3499251pxb; Mon, 9 Nov 2020 12:50:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGhi5hgGjENfBuG3xspMwECdh7s+0pAsnXN7IRwXOs/LK2yqzgq3EUkyd04RyT7zYDihPJ X-Received: by 2002:a17:906:1381:: with SMTP id f1mr16393201ejc.87.1604955049778; Mon, 09 Nov 2020 12:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604955049; cv=none; d=google.com; s=arc-20160816; b=mgHFIyV+Ppph8MOAcqlRshjc8R+dGIB+5KGJAbDpJftTZYd5A2fq3D9tH7Zptl1AhK qxv+bBXQAoBCZZVpSMkh1yxddAzTXZjnt8tXSn35YP6oi7Gb+npKvTsEsfgbj85+Dtee ClhNyQtvyzfC28+ohOZgGYoeQr8wGa8EZYM0opBNGlKPngkeqsMjtlXrYamnF6Tlr4Lk 0wOkB4F0gpN89LVkjJvjcYMgc75AHZNbr9D3pJbKXvntzltbLTE5ZG6gLrlhHoDf+z8c vgskVDEzr2VcZWfx8UlPQj7I0W/5TPSe37C6jtqHd/AW2bTr1ThBaLxWDRL9kzoLGTPf B3Gg== 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=ZSFUi1BZtJUNTipvlzH3vxoVOhF8IWdMf7m44jlunao=; b=kpJAsntLAr3kKwx7fwf7c7rvFrlI334FPMv7t8mRBw5MhStjxuTZaU+iPXY0s3OypP 9UB0+sRTlgHk4cixAoq39X/itw48nxvhqwLAFLgnHXfd3StsiFJthJT93awhCkhZI00F D6nUu3NqNNC8HqKGzsgRAIrJqQFalFryOneNqeF92Y3KEXg2BIO+J4tDf3s+RL9xx6jU OjK04hbO92FlO+7dZV/AvVXCcFrHFk+B3FR0Jp2erdUV32UyRJ8Z7eF7714ydz1ooW66 7XYmNwg1zw+BgyXXOCt6Ji9FRLqc4ezH50Msm5zoBuELQJhWx8fFKmp5+ofhJCQzf5i5 kWJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="BmODR+V/"; 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 d21si7668390ejy.662.2020.11.09.12.50.26; Mon, 09 Nov 2020 12:50:49 -0800 (PST) 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="BmODR+V/"; 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 S1731115AbgKIUrx (ORCPT + 99 others); Mon, 9 Nov 2020 15:47:53 -0500 Received: from z5.mailgun.us ([104.130.96.5]:59049 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730920AbgKIUrs (ORCPT ); Mon, 9 Nov 2020 15:47:48 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1604954868; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ZSFUi1BZtJUNTipvlzH3vxoVOhF8IWdMf7m44jlunao=; b=BmODR+V/BOBS1GL4NpumhZ9mrsfD3DZ4QyW/2uMfgrrsuhIL/gcWP5CBWllqaTnmGK1hUEj8 HYJINJ6TwFqbOYNlOkMNeLLnRUKJ6Kk4cpxi+xHh0yRlblvoiJoj+Ax5OsnL7YVhpnw1qDgI 2Gxz7n9qeDmTgo7c33/6KJnJMX4= 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-n07.prod.us-west-2.postgun.com with SMTP id 5fa9aaf361a7f890a640b718 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 09 Nov 2020 20:47:47 GMT Sender: bbhatt=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D9FA2C433FF; Mon, 9 Nov 2020 20:47:46 +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 BEE12C433FF; Mon, 9 Nov 2020 20:47:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BEE12C433FF 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 v4 12/12] bus: mhi: core: Remove MHI event ring IRQ handlers when powering down Date: Mon, 9 Nov 2020 12:47:31 -0800 Message-Id: <1604954851-23396-13-git-send-email-bbhatt@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604954851-23396-1-git-send-email-bbhatt@codeaurora.org> References: <1604954851-23396-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 Reviewed-by: Manivannan Sadhasivam --- 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