Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -37,6 +37,9 @@ void DeviceOthers::setInfoFromLshw(const QMap<QString, QString> &mapInfo)
setAttribute(mapInfo, "logical name", m_LogicalName);
if (m_Driver.toLower() == "usbfs")
m_Driver.clear();
if (m_Driver.isEmpty() && m_SysPath.contains("usb")) {
m_Driver = "usb";
}
Comment on lines 38 to +42

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): The fallback runs for every USB device with an empty driver, not only when the driver was cleared from usbfs. A genuinely driverless USB device is therefore assigned the synthetic usb driver, bypassing the later unavailable-device handling and causing it to remain available with enable/disable actions even though no driver is attached.

Triggers: When lshw reports no driver for a USB device and m_Avail is not yes.

Suggested fix: Restrict the fallback to the usbfs-clearing path, for example by recording whether the original driver was usbfs before clearing it.

Suggested change
if (m_Driver.toLower() == "usbfs")
m_Driver.clear();
if (m_Driver.isEmpty() && m_SysPath.contains("usb")) {
m_Driver = "usb";
}
const bool wasUsbfs = m_Driver.toLower() == "usbfs";
if (wasUsbfs)
m_Driver.clear();
if (wasUsbfs && m_SysPath.contains("usb")) {
m_Driver = "usb";
}

if(m_Driver.isEmpty() && !m_Avail.compare("yes", Qt::CaseInsensitive)){
setForcedDisplay(true);
setCanEnable(false);
Expand Down
Loading