Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp512416pxb; Thu, 9 Sep 2021 06:11:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEq3kV3hWka2wfbduP1NYxHLJeG3KapRyx+jUE70F7TwE74N7LYmbkdkkkr5UO/l7wf3RJ X-Received: by 2002:a17:906:9241:: with SMTP id c1mr3362285ejx.125.1631193086888; Thu, 09 Sep 2021 06:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193086; cv=none; d=google.com; s=arc-20160816; b=QTcLkXW6WzKmNl7RJgkfsgDqaWfxDiWO5Ac3ICfNiUuLZvalWstFDIo4Ta7MS0L131 mDLH9pVJvWRCPZo4g2lP+MJhHwxoqKYV7SBUhYuNLorRmqj6BN/kV35kQnOCAUnDFaBR mtzEqnkrL491NoENN9F/jEWy89bd9/SWim0HBXoRj63LA0g9tJ7Cj8kDn7W8gNVKLlB/ 5xzutAu8CKm5A4g5FUWzwjVW9J5GN0xMPZCNhxRzEJepqMHLa96WHFCsLwFzbzIWA35U VrltunUFMyafpAeZfw4mbEzHgFo53PFYnRPimYjRucAc72O1mqNtfc12HnPa/6o4vOlj sfMA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H7PJBKSxFVY+K7b4WSnRFK7wu9tq80fo/TrnWqMH9Q8=; b=aGDATNJ/X/oVcafYoMJrMXkEX59UL9vQIYKC9J05uGDhxekd560qOdLfAfQfQybxIn gOZcS4hyvDVw5nZnKudmtQi93fwkEf/u+9Xm9OrwaEzmq3rxvkht1mTrggU74MNBDb+A s4cc3ZMXvH8Cc2k6v+lfGvt2XN3F51+4eOcV3i1Z15b9tlXzTaR3xFmFO2EH4rSaXDl0 LZgJsHkoC14BQFi++xhKEU/t7PWxKQCBTwkQZeejA95sKXbc6UZBe91PdWTnKNH+zvkZ P4IW1P2Sp9dIXDsxhLSDEaxjNMBqfyJKSxjMC+gQH+mYeUMoRsgf7lxwwdOI3shVLy7c VNQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EAqThrW6; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr1si2309816ejc.424.2021.09.09.06.10.55; Thu, 09 Sep 2021 06:11:26 -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=@kernel.org header.s=k20201202 header.b=EAqThrW6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356755AbhIINEI (ORCPT + 99 others); Thu, 9 Sep 2021 09:04:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:40986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354446AbhIIMvK (ORCPT ); Thu, 9 Sep 2021 08:51:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA29163231; Thu, 9 Sep 2021 11:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188626; bh=PHPVcQ5YHYDkAXSwAUXuZYpebFQsZFiC3EuP0KlIyJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EAqThrW6flNPtoeyxepR1lUjxaryJZuyCgXkwlJNtF1BjVv++uY9fmtzUMhm3v5Pp yygjFaliSBCYFiEXIVquz9iOEaf8P2mNfspoChSZBwbp8baWEmRN6FUcSiGtxIyLVx epNHGQPLFiM9Zc/q7d3OzD4/UPqTNmNEMz5RNzywHwt5VS3JVaXsmk9bjW7zop5knw xgmN9j5epFJDD6d3r0U1ZLd+JE6nIch4OaWhu2KI18WM7Ihngy+J0hhPyT6cPWqkoE vdsZtMRUet18BJY61JRBtha9vOrM7t44MzIFHJMGQ4rQTveQO48DcVs0tQLW176QrU pqYp9kfaXqrKA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nadezda Lutovinova , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 094/109] usb: musb: musb_dsps: request_irq() after initializing musb Date: Thu, 9 Sep 2021 07:54:51 -0400 Message-Id: <20210909115507.147917-94-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadezda Lutovinova [ Upstream commit 7c75bde329d7e2a93cf86a5c15c61f96f1446cdc ] If IRQ occurs between calling dsps_setup_optional_vbus_irq() and dsps_create_musb_pdev(), then null pointer dereference occurs since glue->musb wasn't initialized yet. The patch puts initializing of neccesery data before registration of the interrupt handler. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Nadezda Lutovinova Link: https://lore.kernel.org/r/20210819163323.17714-1-lutovinova@ispras.ru Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/musb/musb_dsps.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 327d4f7baaf7..89d659cef5c6 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -890,23 +890,22 @@ static int dsps_probe(struct platform_device *pdev) if (!glue->usbss_base) return -ENXIO; - if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) { - ret = dsps_setup_optional_vbus_irq(pdev, glue); - if (ret) - goto err_iounmap; - } - platform_set_drvdata(pdev, glue); pm_runtime_enable(&pdev->dev); ret = dsps_create_musb_pdev(glue, pdev); if (ret) goto err; + if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) { + ret = dsps_setup_optional_vbus_irq(pdev, glue); + if (ret) + goto err; + } + return 0; err: pm_runtime_disable(&pdev->dev); -err_iounmap: iounmap(glue->usbss_base); return ret; } -- 2.30.2