Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp518541pxb; Thu, 9 Sep 2021 06:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMFK9uJJ4M1QZoOArClIOuph/S5UQrcsUCTo/aLnDuM0D1Q0E0S6twgn9tvv5bTiWGPa3c X-Received: by 2002:a92:dd88:: with SMTP id g8mr368215iln.306.1631193494018; Thu, 09 Sep 2021 06:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193494; cv=none; d=google.com; s=arc-20160816; b=QS4AR2MPBLxA8RVY2VPUO7G48FTNOzcPOuI6XMqZ7RXHV09U3OHLV/Rp2d/zwqnUp9 Y1qlt30s04lmQLqtxzyhLVZJ66qzVeaJX+2strHuQ3eeKlbuZU80KdS6ZQ3RzwKXSc1R jl4rrkg4miMFXVth0dum771fg/483eSHD5/AKsJxBa4hE+LJ2IiwUKI+SjY2hs7a1iey pgSgpkO/1iKl+Ng8avTFKWyK+7ZKKTJNS4uBDvAHy3/maHkZ55EGzqtd4JOq0gvAzGsl pHHepBtuwAh/2YBnkBFLMxbYDAtacDgXLMfeFrZ82PLk/33J7g+tXL8U8GYXbIyD6zGV +vfg== 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=iEW1PP+cIGuvudyHekXdgVli4B7syxymeUOrhL0fQCM=; b=VVLZ3Lx1t+/vN55UhdViAfWqfrY7SsPZmPDKkOxbRvnONr29G2zR3ST2YpoH/XFdDj MDxWhDkPhajBo2U6GtoG225lC6PEWyiCpXO6R4yJom0VGT6nvKm8Nr6NE0KWRSTm7xGq LKgRZ+lRHl6JfIzVCglO5CNWkqIiTc5x817U4d6afjk0qJ39x7kAzrxP3ML70EtuKGTc Rn2S4AjXWDs6Jt+zt6lboLLagB0dn0UKgeAfv57Wdb7YEZB7qUuwIbpzJer96WrThesU iEUvQxG7xiLKG3jOepwqlC6ka92WFzia1RK1fAaeo00gC5SDaoYA6u+9+vIhE8DNiILy GfGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RigmaCbj; 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 y20si1833975jao.34.2021.09.09.06.18.01; Thu, 09 Sep 2021 06:18:14 -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=RigmaCbj; 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 S1356278AbhIINSR (ORCPT + 99 others); Thu, 9 Sep 2021 09:18:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357885AbhIINFS (ORCPT ); Thu, 9 Sep 2021 09:05:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A371963280; Thu, 9 Sep 2021 12:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188803; bh=cJuvfYSyGsgXQlB4XaacXMJyw9FoYiKpfP6CmbpT0+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RigmaCbjp0CoM5rYfq0wmrOtH8nI4+7xttdN2eUzhbuYz92fyyXXskESIxcjlRJTw senCtcIMqks+2l8PBYld+F44kounFQ5EqlcnkbS2zhsQxM4YKuYPkfS0BEZrNdhYL5 p0bDHW9bFCZSV2T07EZaPBCVX1o9t18UjqnRjtyEbT+EvkAi8sTJcabb38hYjwTD0A l6YtBX3boxnO8jfSimd2Tl8RiKlKscXDjad+3wPRHvLMh9t1PwIFAf1SpAYbRnxMAd zjNmqfTf/imfV7mamRb8VW5vxMC/nRLmjLK0m6oJMqjFlFS/OHkFN4jEMsrmeE/LAJ g2eU41xFUGT1g== 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 4.14 50/59] usb: musb: musb_dsps: request_irq() after initializing musb Date: Thu, 9 Sep 2021 07:58:51 -0400 Message-Id: <20210909115900.149795-50-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 b7d460adaa61..a582c3847dc2 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -930,23 +930,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