Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3009602pxb; Mon, 18 Oct 2021 06:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjibjCXtfqp9utN/osC4RBVSMaGYDN6tIOVVhlLnd+i6QshLu8atFbn9s+1DZAz5fL47Ea X-Received: by 2002:a05:6a00:b45:b0:44d:c4c4:409b with SMTP id p5-20020a056a000b4500b0044dc4c4409bmr8972902pfo.3.1634563935313; Mon, 18 Oct 2021 06:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563935; cv=none; d=google.com; s=arc-20160816; b=fOOiTR1mUpt1rAQLYGY9HgES7Ns2rnoA2g3YlNlRXNaL9MosAJBDUrHhj8CXXFsbOx Hw8dAIhB2YmWnR5TCyX9MpzMzPqZWoGNL17HUaiEANZYGk6tPmX7ORKvQS/b/6kszIi6 jW7MpXvvQPZvCleCKlJBEMiQYVS3zrWE1ystvJFMTIaE2ToOMzvSMym9ehwIxgFT1FhE VudGZay5jqUV3iMGC1qe/iQijtepNV+Cl/T5JxiTGgLfDrQBDBsQwBVuD2jWKYn0MJ0f +gQcpZfE685kcQEFhzEr+ocmpJz+3z+0cjQs4U5qDP88us1tghI5fW482cTWMQR6wYb4 Jkeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YSJ1ov0FZ48B0EzkjtdKpyevYT0KmXGcccWGY5aC2Jc=; b=GawIXaB3JWdEAu05f6dmacgKBYLlRhsVULlMbVbG+hDUeDk+f7Z0zD6wmAfj9MhJok X0v/lIUt+BKRbjlAwFT+hsUudnXsCworbJX9wjYTH+QzuYLUPnGjIfQt5/z5Av8Jglqr zSHZ7x/3WHiBrLYgF+JbLiJ3z/56HuDWodgDtqSyoDSjlJhIGWQcAYfiVdtVwa0ZNfwW 7NFLbBHpmZjoaPGv45a5EGcI4GVZFQOlgHv3cgbIp26MUOMWff91zfZu2Ufn0Fxf/2bQ /o2YhW3YvfZpxS5lr4rbmedsNMrgZ81uX7gc3nWQadPHe3CubRFpl7DAxE9ewM4tYgBa w/rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CZmBzIlB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si30379339pjg.134.2021.10.18.06.32.01; Mon, 18 Oct 2021 06:32:15 -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=@linuxfoundation.org header.s=korg header.b=CZmBzIlB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232890AbhJRNbq (ORCPT + 99 others); Mon, 18 Oct 2021 09:31:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:43310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbhJRNaB (ORCPT ); Mon, 18 Oct 2021 09:30:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E239B61371; Mon, 18 Oct 2021 13:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563670; bh=0It4JOOzgnKHbcrcc2XMXzDqW/2yk8htv0WdXjeYluc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZmBzIlB5gWmdWQLpb7g11I+upgOSYItUCp5zqBqsZJK1BKLFo8nH0kJjDBEgNg5q +Ggx0xB6Kidm3QabKhipPf8rVIyKyz8RcpBe226VAEOHYwW/ou5unvnlYNqtL1nCwj 2u8IVNDXFN5gmqUCKYjGf5Hg+TQ0nMiWuHfHfzRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal Subject: [PATCH 4.19 18/50] usb: musb: dsps: Fix the probe error path Date: Mon, 18 Oct 2021 15:24:25 +0200 Message-Id: <20211018132327.142225652@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132326.529486647@linuxfoundation.org> References: <20211018132326.529486647@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal commit c2115b2b16421d93d4993f3fe4c520e91d6fe801 upstream. Commit 7c75bde329d7 ("usb: musb: musb_dsps: request_irq() after initializing musb") has inverted the calls to dsps_setup_optional_vbus_irq() and dsps_create_musb_pdev() without updating correctly the error path. dsps_create_musb_pdev() allocates and registers a new platform device which must be unregistered and freed with platform_device_unregister(), and this is missing upon dsps_setup_optional_vbus_irq() error. While on the master branch it seems not to trigger any issue, I observed a kernel crash because of a NULL pointer dereference with a v5.10.70 stable kernel where the patch mentioned above was backported. With this kernel version, -EPROBE_DEFER is returned the first time dsps_setup_optional_vbus_irq() is called which triggers the probe to error out without unregistering the platform device. Unfortunately, on the Beagle Bone Black Wireless, the platform device still living in the system is being used by the USB Ethernet gadget driver, which during the boot phase triggers the crash. My limited knowledge of the musb world prevents me to revert this commit which was sent to silence a robot warning which, as far as I understand, does not make sense. The goal of this patch was to prevent an IRQ to fire before the platform device being registered. I think this cannot ever happen due to the fact that enabling the interrupts is done by the ->enable() callback of the platform musb device, and this platform device must be already registered in order for the core or any other user to use this callback. Hence, I decided to fix the error path, which might prevent future errors on mainline kernels while also fixing older ones. Fixes: 7c75bde329d7 ("usb: musb: musb_dsps: request_irq() after initializing musb") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/r/20211005221631.1529448-1-miquel.raynal@bootlin.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_dsps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -901,11 +901,13 @@ static int dsps_probe(struct platform_de if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) { ret = dsps_setup_optional_vbus_irq(pdev, glue); if (ret) - goto err; + goto unregister_pdev; } return 0; +unregister_pdev: + platform_device_unregister(glue->musb); err: pm_runtime_disable(&pdev->dev); iounmap(glue->usbss_base);