Browse Source

Fix crash in tdehwlib on partitions without parent disk

This applies for example to the software RAID defined in the BIOS

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 3 years ago
parent
commit
36481f68c1
1 changed files with 9 additions and 6 deletions
  1. 9
    6
      tdecore/tdehw/tdehardwaredevices.cpp

+ 9
- 6
tdecore/tdehw/tdehardwaredevices.cpp View File

@@ -2595,18 +2595,21 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
2595 2595
 			TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
2596 2596
 			TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
2597 2597
 
2598
-			if (TQString(udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER")).isEmpty()) {
2599
-				disktype = classifyDiskType(dev, devicenode, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
2600
-			}
2601
-			else {
2602
-				// Set partition disk type and status based on the parent device
2598
+			TDEStorageDevice* parentdisk = NULL;
2599
+			if (!(TQString(udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER")).isEmpty())) {
2603 2600
 				TQString parentsyspath = systempath;
2604 2601
 				parentsyspath.truncate(parentsyspath.length()-1);	// Remove trailing slash
2605 2602
 				parentsyspath.truncate(parentsyspath.findRev("/"));
2606
-				TDEStorageDevice* parentdisk = static_cast<TDEStorageDevice*>(findBySystemPath(parentsyspath));
2603
+				parentdisk = static_cast<TDEStorageDevice*>(findBySystemPath(parentsyspath));
2604
+			}
2605
+			if (parentdisk) {
2606
+				// Set partition disk type and status based on the parent device
2607 2607
 				disktype = parentdisk->diskType();
2608 2608
 				diskstatus = diskstatus | parentdisk->diskStatus();
2609 2609
 			}
2610
+			else {
2611
+				disktype = classifyDiskType(dev, devicenode, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
2612
+			}
2610 2613
 			sdevice->internalSetDiskType(disktype);
2611 2614
 			device = classifyUnknownDeviceByExternalRules(dev, device, true);	// Check external rules for possible subtype overrides
2612 2615
 			disktype = sdevice->diskType();						// The type can be overridden by an external rule

Loading…
Cancel
Save