Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1539001pxb; Thu, 16 Sep 2021 09:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt4WSaNJdyiHMT6JK+lZPXKfl5ZWma9ZJmmsM/tFgomhbTxHUX0rew795eXCWCILmxFTV8 X-Received: by 2002:a6b:d209:: with SMTP id q9mr5198340iob.206.1631809808455; Thu, 16 Sep 2021 09:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809808; cv=none; d=google.com; s=arc-20160816; b=LKhgXwZul8qg5zV1FtJrtmvoJX2Jevpl+s67RF/w1GmUZS4Bbwd/o3ZFgVnjwgRwv0 aSCZZICiSt7TyqF8nfxWI8R18FqzRZB8vH/NwdO4aIWqPUutmakP3OmpJ0fMWuhFsc2n 2SJ4KNFaSMnN12ScSpVmZjRFWorkD6F3urbe7DXTblEd6gt83qicBh8s8ErQoeR0cqbr w7yiaOszRNvD6B4pApMxgv6MDWlnKXY4yGVAMdouUNDF++TIxU5IbWjuQrrKPlE/Gdtd CuHSsDR6lpCQammS4vX5ONpb68cSYDoj3gJq10GhBHE5B2G4IwyoHZKwwU/AlJYVtZ65 QrcQ== 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=G+SEWTyGU8vzRhrcSP8W2iD8PydVDb4MqjhJjLXa+7k=; b=nKJyWofEL26b4U+FFgqP4Hy1yniPmOYqm6zFJ/C6Ln3GJxpeAwPxQKMvUadUdQjeWn QYEDXhA6OxWK0MOe5xXcekXncmULXyNBQZc+EaohHnupDTt1H8Li0zqMqH05HZVeQoqK pmmiFSQBnOINxigT1ZvCHrPnEcMVCU8cmj0aBBYItkqEIGMLlkx8poLdp+s4sAktRx2C 0u4wmrU4f6ADn4HQt9SQDMo5oGJJa6VZh/RTCc7eBbxdG93f5+m+AqR99XDps/jcESCW Qq2QkeHWkY/eYNolkMKA7wlzpvWrdLuwycGVvQaWXgoH0sntFwffHj/S/buXwSNT3YuL hEDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iQ5K9q3M; 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 l6si2807881ilh.90.2021.09.16.09.29.56; Thu, 16 Sep 2021 09:30:08 -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=iQ5K9q3M; 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 S243036AbhIPQ3z (ORCPT + 99 others); Thu, 16 Sep 2021 12:29:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:59974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240700AbhIPQUb (ORCPT ); Thu, 16 Sep 2021 12:20:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3CC2E613A1; Thu, 16 Sep 2021 16:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808871; bh=L+Zrw3R7HuZQRklNozrduxknMAPTxCggBqZfIcjfZ9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQ5K9q3M/5H0KsBeOVQEFD8K/oahGvfNVWZiRdFm9vheLGszL4N1LSP5WJrDVNMUL L4nQa94OFj0QKbFwAw5UObBmwwzH039VFxXiU8aNvEwUx6yOqm+0DaQxgsDmtfATmw KuA2mRCS/gCEQckVbEn2Z8vVLPlXSgJWZDoQK+q4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nadezda Lutovinova , Sasha Levin Subject: [PATCH 5.10 254/306] usb: musb: musb_dsps: request_irq() after initializing musb Date: Thu, 16 Sep 2021 17:59:59 +0200 Message-Id: <20210916155802.728071332@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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: 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 5892f3ce0cdc..ce9fc46c9266 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