Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3012792pxb; Mon, 18 Oct 2021 06:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYCd9Bk20gup0+82VQ81mjTDsBE/GcNO8glMcBSlLpDquZXIMn6URBVmXw90WJx1yZ6X8c X-Received: by 2002:a63:1444:: with SMTP id 4mr23377762pgu.251.1634564152050; Mon, 18 Oct 2021 06:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564152; cv=none; d=google.com; s=arc-20160816; b=FwMDehCt+8IOwPQx6PDHK7JrcL86rt9JVA4HMWJ2/xk+d47bV3+vWJOPdkpJ8k9TI4 JqZqJZ7IqI0xW9b5fxjCjPpZH/1a4M0A6o2Md7NmYzlxOpA0BGz6iF8EZAA67sVYqs6i vKhDixbJnCYwou0jhuacEbTi0VNw7vKyCs+9gqoMkYTBh95ePQr8qitSDohNnxErx41I T3sEfmJSrwdDJ20ZjLiw1OLdPZwdBOssOQU27ExQGYYmbmzA9cJjBVXWe+NE74FSmzOG iRzCUiLxfs7kRFiZnvrsoig73w8YzrR7jM4PGccEy4CIC60kwi59NNjBhJrOQb4kyTw4 w4Pw== 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=cDcORg59jGnWRCpphneXWVXcCualeQlH4s3CJgvFuqQ=; b=GjKYR4ZLdfN/cSr4pNknT4ZnN3VpbDRcI80ZhdWvOIZIEz1fuHU69kCebbs0oYOepx lqpkNfVGbrnconuOGilFCkUrsw1M7smroXlm/u+lBoYfU+V2vWZVrlrW9TsE7hvJFj/N Qiaw+SFFnH3o71w9VNlhc1PpQpmBLkZeZMIdLneLnCjVMW3qjw5ygwa1MuUmzaBMjIZE qCDomhPVjBZZVTAjaTQJcopDpvk3aIeFdU5AaXH+VIt1FW+xM+l0enXX9+3monAYOV6d FeOgtHflOrq5UfFtzTj6u+lyfRdFpe/hHbUda/LkqINtjx/aXv135DRWk2Lp3cJT2Bk8 vgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KZqt4UXR; 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 f10si21377645pgv.131.2021.10.18.06.35.34; Mon, 18 Oct 2021 06:35:52 -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=KZqt4UXR; 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 S232370AbhJRNgW (ORCPT + 99 others); Mon, 18 Oct 2021 09:36:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232698AbhJRNeo (ORCPT ); Mon, 18 Oct 2021 09:34:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0CBD61353; Mon, 18 Oct 2021 13:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563814; bh=Vw6ttr68ZCstAPpVVICipZAA0bc2xWlXeF1vrKCNfus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KZqt4UXRp49cds4khGaF2FlPYbRTTd3n9Eik4pKYdrl7xXpDMB8jaPpyUFar9xmAS oWIZA4h324/UUe6If/g/oSTokIYSs6xFnl6fqkAa9ARc3BWlNeb8mgXKMXnHsisW5U XM8Y9kGVfzBLCPUCmyJue6NT0F5rL4XYGy9npxvE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal Subject: [PATCH 5.4 25/69] usb: musb: dsps: Fix the probe error path Date: Mon, 18 Oct 2021 15:24:23 +0200 Message-Id: <20211018132330.297872087@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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 @@ -899,11 +899,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);