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=1796382370; b=HBFZFEkRrDw8ThchLEbbDv4877lQMHUhpSOjmohzENG9BRKORBiXbGR/j1IsBxzybWmk 47Pf03APPF3FNzec0eVZ7XPNMq1UEq230mxPoNcjdX2WDdbm31UWRWsgZ9MdKJi4mq5QM F4lU4m8cCfZn8aDyNC2JFnWTKyuN2kip2rlyffuJKH4d+Sc02HWhRGJGNBKvaOqVDPeLB yL5UFND2uwBPELI09znDBfzufzDbkUvDGxtjWVEGzboVP7DmtSpVII9E1qfrSgb7qx5RN SdVknv/o8bsAJlqGPYTkn+fYidAgpLeWVsWmQ7FPQcW7+Go6AjzMWYmn3MG0+KDlRPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382370; 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=NJFdtGHgmQWICEcpmpxUmtVN3hS8s+UZj3SbfXWc+QI=; b=NYeBfOpZs+2o9ndGZwbrDueuLxfrBXJ3Z+5cw06v/YDVM3db3RPrg2CC2JSuFNfad7Hq bocm1JvOd4qERu0h0pQNwmWunS2B1oVeSarni3LtQgfwE1q3+hzP7VGIHGFdxTw/eey9r abjj2VcJjVaTlTcAyBI9p7zeuMcpMztXAhjSV61qr6KyHyWcux5xJ4sXCLsFcmrhbm5vq LM6aaM+tXEd+75vuP/UQ604qCYvQlQOGIC1A5HSVorxYcusGtH6R3pwJwpIs1SuXQKxB0 VS91KLB8W6yGn1wIr0X7I8FUlzE8bDEQnjZgEOrWRWIu0O/NZcK7F2YSrtJaa3/BMvA== 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=avM6XfTG; 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 85E37606A322; Fri, 4 Dec 2026 11:06:10 +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=avM6XfTG Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF29C1F000C2; Fri, 4 Dec 2026 11:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382370; bh=NJFdtGHgmQWICEcpmpxUmtVN3hS8s+UZj3SbfXWc+QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=avM6XfTG/S56SyQ7HkWXa18nAJvoy3lUjP+p2oL81jLLq7cQVmJ6xh7wj38vAIQJW TDHv7RWrv+cfhTIGrYTa4eJdWweqLMFTLN2IzqyeHjE/1WwQ5nXtYySB6GGYriiKiF 6CtbKUnVgyA1caF4uhX3g4Q9teJklnnaz2q83ncM= 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.18 424/703] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Date: Fri, 4 Dec 2026 19:05:23 +0900 Message-ID: <20261204100639.102514748@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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",