From patchwork Thu Aug 27 09:22:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 11740339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 818461731 for ; Thu, 27 Aug 2020 09:23:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6069422BEA for ; Thu, 27 Aug 2020 09:23:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="RuipkW0m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728520AbgH0JXg (ORCPT ); Thu, 27 Aug 2020 05:23:36 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:60447 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728401AbgH0JXd (ORCPT ); Thu, 27 Aug 2020 05:23:33 -0400 X-UUID: c6ec64b1d9cd4f118c4f7a3070a9774b-20200827 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=S4CfLutE8hUT3EWA7X8xikOPUUz72YCt0QmrL0S0o10=; b=RuipkW0mMnh8/+7ZcKhlpn2NZL+srPzHlp3S1Rjj0PlVd1QR+QPuofPFxemm55YaPAahwCqB1uGaTZGA18yH6isTzj4VHXqprGQXVsNvZL40m1s6XpmAD4JGu0fK985Z6wZSy3IHRAFzb2D5RndSNlCvNe1UTctnuAf3wX9/2UM=; X-UUID: c6ec64b1d9cd4f118c4f7a3070a9774b-20200827 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1025482517; Thu, 27 Aug 2020 17:23:29 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 Aug 2020 17:23:26 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 27 Aug 2020 17:23:26 +0800 From: Macpaul Lin To: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , , , CC: Ainge Hsu , Eddie Hung , Mediatek WSD Upstream , Macpaul Lin , Macpaul Lin , , Subject: [PATCH v3] usb: mtu3: fix panic in mtu3_gadget_stop() Date: Thu, 27 Aug 2020 17:22:58 +0800 Message-ID: <1598520178-17301-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1596185878-24360-1-git-send-email-macpaul.lin@mediatek.com> References: <1596185878-24360-1-git-send-email-macpaul.lin@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch fixes a possible issue when mtu3_gadget_stop() already assigned NULL to mtu->gadget_driver during mtu_gadget_disconnect(). [] notifier_call_chain+0xa4/0x128 [] __atomic_notifier_call_chain+0x84/0x138 [] notify_die+0xb0/0x120 [] die+0x1f8/0x5d0 [] __do_kernel_fault+0x19c/0x280 [] do_bad_area+0x44/0x140 [] do_translation_fault+0x4c/0x90 [] do_mem_abort+0xb8/0x258 [] el1_da+0x24/0x3c [] mtu3_gadget_disconnect+0xac/0x128 [] mtu3_irq+0x34c/0xc18 [] __handle_irq_event_percpu+0x2ac/0xcd0 [] handle_irq_event_percpu+0x80/0x138 [] handle_irq_event+0xac/0x148 [] handle_fasteoi_irq+0x234/0x568 [] generic_handle_irq+0x48/0x68 [] __handle_domain_irq+0x264/0x1740 [] gic_handle_irq+0x14c/0x250 [] el1_irq+0xec/0x194 [] dma_pool_alloc+0x6e4/0xae0 [] cmdq_mbox_pool_alloc_impl+0xb0/0x238 [] cmdq_pkt_alloc_buf+0x2dc/0x7c0 [] cmdq_pkt_add_cmd_buffer+0x178/0x270 [] cmdq_pkt_perf_begin+0x108/0x148 [] cmdq_pkt_create+0x178/0x1f0 [] mtk_crtc_config_default_path+0x328/0x7a0 [] mtk_drm_idlemgr_kick+0xa6c/0x1460 [] mtk_drm_crtc_atomic_begin+0x1a4/0x1a68 [] drm_atomic_helper_commit_planes+0x154/0x878 [] mtk_atomic_complete.isra.16+0xe80/0x19c8 [] mtk_atomic_commit+0x258/0x898 [] drm_atomic_commit+0xcc/0x108 [] drm_mode_atomic_ioctl+0x1c20/0x2580 [] drm_ioctl_kernel+0x118/0x1b0 [] drm_ioctl+0x5c0/0x920 [] do_vfs_ioctl+0x188/0x1820 [] SyS_ioctl+0x8c/0xa0 Signed-off-by: Macpaul Lin Cc: stable@vger.kernel.org --- Changes for v3: - Call synchronize_irq() in mtu3_gadget_stop() instead of remembering callback function in mtu3_gadget_disconnect(). Thanks for Alan's suggestion. Changes for v2: - Check mtu_gadget_driver out of spin_lock might still not work. We use a temporary pointer to remember the callback function. drivers/usb/mtu3/mtu3_gadget.c | 1 + 1 file changed, 1 insertions(+) diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 1de5c9a..1ab3d3a 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -564,6 +564,7 @@ static int mtu3_gadget_stop(struct usb_gadget *g) spin_unlock_irqrestore(&mtu->lock, flags); + synchronize_irq(mtu->irq); return 0; }