From 36481f68c1cbb7c55a7325d709311e20b9c2ce54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 11 Feb 2016 00:47:11 +0100 Subject: Fix crash in tdehwlib on partitions without parent disk This applies for example to the software RAID defined in the BIOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- tdecore/tdehw/tdehardwaredevices.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tdecore/tdehw') diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index cf11d8b6b..9c5a0833d 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -2595,18 +2595,21 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType(); TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null; - if (TQString(udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER")).isEmpty()) { - disktype = classifyDiskType(dev, devicenode, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver); - } - else { - // Set partition disk type and status based on the parent device + TDEStorageDevice* parentdisk = NULL; + if (!(TQString(udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER")).isEmpty())) { TQString parentsyspath = systempath; parentsyspath.truncate(parentsyspath.length()-1); // Remove trailing slash parentsyspath.truncate(parentsyspath.findRev("/")); - TDEStorageDevice* parentdisk = static_cast(findBySystemPath(parentsyspath)); + parentdisk = static_cast(findBySystemPath(parentsyspath)); + } + if (parentdisk) { + // Set partition disk type and status based on the parent device disktype = parentdisk->diskType(); diskstatus = diskstatus | parentdisk->diskStatus(); } + else { + disktype = classifyDiskType(dev, devicenode, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver); + } sdevice->internalSetDiskType(disktype); device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides disktype = sdevice->diskType(); // The type can be overridden by an external rule -- cgit v1.2.1