Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp578487iog; Mon, 13 Jun 2022 08:29:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8R+kKwPgVcrg86JXP6NK3Gh6fr8R8bCHXYh3HlsJEJFC+I3Fobu76AbehNuHeXC0386JD X-Received: by 2002:a17:90a:94cb:b0:1e3:4295:9c18 with SMTP id j11-20020a17090a94cb00b001e342959c18mr344290pjw.53.1655134172569; Mon, 13 Jun 2022 08:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134172; cv=none; d=google.com; s=arc-20160816; b=O8/iv2yVcZm8wcgjKjdzWyVlSJutWsRRxKDMXSnzj625l80oN1LHbRelORYn2jynm5 mE8XGzW3mz0U5Goa5XJYTc5QTNgQpqm2K8jdnSH7ppmvzzJpNVquQ3d1ztBR1FSP3hOD ILXJqJTYEQCdRzC1HMvh4YCuQk9Uu9ATl9qhzM01W6x+K2RtfQTOkFFZP5XikXtiQ1IN aJtfTEqB2RUfvzi+EAUcChlAgePd9Lk1OGL4xyMPSEEkzOgkN6tHVZzTq3QvSg6Hele9 YEejtRuTHX0Etiekmsy5PWpP+RVVg1Xptim9q0h1DomnhgGJ9bVWd4K+han+zKDQeCNL /zpA== 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=aZl2fxpPhDGS2ASrl5eTzlY1dAQSHGChM+v+ZaawZT8=; b=WOGM/YxdpKayRDhXZOdg4cn69J7JL1ZrRp0BX13mQdbFQxsvGwm5xPQHcjmmMqYeQ9 ub5B3jAH1EPs01SW/F1J0rVEnIKeZ2wZy4t4Bb0hfCwM5FL++lEkHxIhgmYiaPxENBqf vdsfMZCgbfG6o0PXhcrr9/dUbea6UoFq0f5v71eGqdQU+6XX68BcCUGYcBI7FIyg6eEJ 54Q0NGyucGxM+sf97NuqQ3XqpVqClsGSMzsRUXh+ZQsCBxDYIfJfXMir8B3dk/WyI1sl hjBw/x7ibMy+A6vHgwVCBcdy+hzooLhTuqNbmqVeP3KoTq5/HLH75xq6Jir2P1OqkYK4 f6RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rNO64tvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a17090b070a00b001e839b85f69si8701427pjz.47.2022.06.13.08.29.19; Mon, 13 Jun 2022 08:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rNO64tvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352112AbiFMLKm (ORCPT + 99 others); Mon, 13 Jun 2022 07:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351892AbiFMLFM (ORCPT ); Mon, 13 Jun 2022 07:05:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CA22A2; Mon, 13 Jun 2022 03:34:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 000B261127; Mon, 13 Jun 2022 10:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DF67C341CC; Mon, 13 Jun 2022 10:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116486; bh=AQJUPapWjuLINSh4e/xYgsJ69ZfH1rTid70rZGLesfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNO64tvBphTONCPUS+RzgJ/S7mPKJlYJpgEhGVJI6tjm/G4ljKd+UX/T0dmc+yNGm N9LX7bO7sumqhEIhVRXeuAsRBr+IE16y3YM8vIeYH/YLu5l8Ix6C8g2TM06xPZOcuF 4iwRN+vGDV7eKsvbveZ5VSx+ptrh4FmDUtsS8kdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Sasha Levin Subject: [PATCH 4.14 190/218] usb: dwc2: gadget: dont reset gadgets driver->bus Date: Mon, 13 Jun 2022 12:10:48 +0200 Message-Id: <20220613094926.379946681@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Szyprowski [ Upstream commit 3120aac6d0ecd9accf56894aeac0e265f74d3d5a ] UDC driver should not touch gadget's driver internals, especially it should not reset driver->bus. This wasn't harmful so far, but since commit fc274c1e9973 ("USB: gadget: Add a new bus for gadgets") gadget subsystem got it's own bus and messing with ->bus triggers the following NULL pointer dereference: dwc2 12480000.hsotg: bound driver g_ether 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000000 [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: ... CPU: 0 PID: 620 Comm: modprobe Not tainted 5.18.0-rc5-next-20220504 #11862 Hardware name: Samsung Exynos (Flattened Device Tree) PC is at module_add_driver+0x44/0xe8 LR is at sysfs_do_create_link_sd+0x84/0xe0 ... Process modprobe (pid: 620, stack limit = 0x(ptrval)) ... module_add_driver from bus_add_driver+0xf4/0x1e4 bus_add_driver from driver_register+0x78/0x10c driver_register from usb_gadget_register_driver_owner+0x40/0xb4 usb_gadget_register_driver_owner from do_one_initcall+0x44/0x1e0 do_one_initcall from do_init_module+0x44/0x1c8 do_init_module from load_module+0x19b8/0x1b9c load_module from sys_finit_module+0xdc/0xfc sys_finit_module from ret_fast_syscall+0x0/0x54 Exception stack(0xf1771fa8 to 0xf1771ff0) ... dwc2 12480000.hsotg: new device is high-speed ---[ end trace 0000000000000000 ]--- Fix this by removing driver->bus entry reset. Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20220505104618.22729-1-m.szyprowski@samsung.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/gadget.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index dddc5d02b552..14f907cf71a3 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -4302,7 +4302,6 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget, WARN_ON(hsotg->driver); - driver->driver.bus = NULL; hsotg->driver = driver; hsotg->gadget.dev.of_node = hsotg->dev->of_node; hsotg->gadget.speed = USB_SPEED_UNKNOWN; -- 2.35.1