From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383908; b=IlowtPbNLlFUqhAJUXH9pev+Pad8bI0qEMwULQCMkisw6eqSWRjYtWjXe/gK+u3Rwnlr eAu9tnL2Dt6pfYuEn0ZPVYRW5ow2p4QR+QmryQRMfu9yRWNPYLwdkJZrlck4vtuBKYjo2 3KNJ/cx13fGnr6rf7Qw0h6Srk7PjCSjKt6pYYQVbGjd4J8bZ65ul1Osz/lgU+/TPUG9Sy 17md+8l6Ln16VZUB9nWUnVfK0540+aWtXcF77l7AeMbjJ+hCtxRt1lpoKR/VINTdMZzRd hkIvWhY4rMcTcB8OGJaJSgD+vGBhtKJQTnR6q1SUTermGUHknkP9vx7DMO4wfWWbPKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383908; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=zssKTHDtEb/DZPujwsI+Nu/tjrW/qPo3GC9zTGxW2uM=; b=J5W0BRAbXYo4lfpNTWP4FNry6po/F/L/oNplng8jwA0GxAvtTtTyOr9CtQ9bRS+BEF3u p4pLoP2+zd7c39a9WMxB1yvcQ39OS8fy1oDulne1ROV4Jkj/3fFwZZOpf3Ipcb77tqzI0 ojD/iVC9Yl36MNK+rVFeyMG3V/aaoGWlrVKQ4sw1AeFroD7+M+KLMUSd85z2TBG+DjZKX +gXDWbr45sDq84Zy1yuYT2aRkl2NEYxBNcDaQxHwAwcQ0M0lXm35i3055unKKN+1owtRE mC1JVyCwEyw0plcArZHDjluuofEbqqIQEf77ozdSjkUnwp83699mVVq7s5Gkt+lSDCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vj3R3wVK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E19860A2621; Fri, 4 Dec 2026 11:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vj3R3wVK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12C6C1F02EEF; Fri, 4 Dec 2026 11:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383907; bh=zssKTHDtEb/DZPujwsI+Nu/tjrW/qPo3GC9zTGxW2uM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vj3R3wVK6bmQD5WHk4Sd0vAAnkFo6gn/hBS/D/EgmZ28QkGpb1bs/Qaovc63vrSmr Hxai+ZwJZvDI8kWBDX8487bxvVq0PGvUE2Hb5AoDFQH49KwqYITfogfcvxS1CbsBLz S8E4hZlY+hX3zpzGNTOH+ziedqlSpkF5cJlv9D3U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, YuanZhe Liu <25031212351@stu.xidian.edu.cn>, Helge Deller Subject: [PATCH 6.12 378/555] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Date: Fri, 4 Dec 2026 19:07:01 +0900 Message-ID: <20261204100624.249192485@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: YuanZhe Liu <25031212351@stu.xidian.edu.cn> commit e8645fe7419828fd95a90171149c565c1bb72911 upstream. ufx_usb_probe() stores the usb_device pointer in dev->udev without taking a reference, and ufx_usb_disconnect() does not wait for in-flight control transfers. A mode set or blank request that runs while the device is being unplugged - through ufx_ops_set_par() or ufx_ops_blank() on an open /dev/fbN file - keeps issuing synchronous control messages for the whole ufx_set_vid_mode() sequence, including two msleep(1) delays in ufx_config_pix_clk(). Once the disconnect callback returns, the USB core may release the usb_device, and the next ufx_reg_write()/ufx_reg_read() dereferences dev->udev through __create_pipe(): general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] SMP KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] RIP: __create_pipe include/linux/usb.h:2031 Call Trace: ufx_set_vid_mode ufx_ops_set_par fb_set_var fb_set_var_from_user store_rotate Take a reference to the usb_device in ufx_usb_probe() and drop it in ufx_free(), so dev->udev and dev->gdev stay valid until the last ufx_data user is gone. The control transfers then fail with -ENODEV instead of dereferencing freed memory. Also return early from ufx_set_vid_mode() while the device is inactive, matching the other transmit paths. That check alone is not enough, because it is not serialized against ufx_usb_disconnect() and the transfer sequence continues after it; it only avoids a long series of failing transfers. Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters") Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/smscufx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -661,8 +661,12 @@ static int ufx_set_vid_mode(struct ufx_d u32 temp; u16 h_total, h_active, h_blank_start, h_blank_end, h_sync_start, h_sync_end; u16 v_total, v_active, v_blank_start, v_blank_end, v_sync_start, v_sync_end; + int status; - int status = ufx_reg_write(dev, 0x8028, 0); + if (!atomic_read(&dev->usb_active)) + return -ENODEV; + + status = ufx_reg_write(dev, 0x8028, 0); check_warn_return(status, "ufx_set_vid_mode error disabling RGB pad"); status = ufx_reg_write(dev, 0x8024, 0); @@ -1067,6 +1071,7 @@ static void ufx_free(struct kref *kref) { struct ufx_data *dev = container_of(kref, struct ufx_data, kref); + usb_put_dev(dev->udev); kfree(dev); } @@ -1610,6 +1615,8 @@ static int ufx_usb_probe(struct usb_inte dev->udev = usbdev; dev->gdev = &usbdev->dev; /* our generic struct device * */ + /* keep the device alive until the last ufx_data user is gone */ + usb_get_dev(usbdev); usb_set_intfdata(interface, dev); dev_dbg(dev->gdev, "%s %s - serial #%s\n",