OSDN Git Service

kioslave: MTP slave crash fix
authorIvailo Monev <xakepa10@gmail.com>
Mon, 12 Jul 2021 23:44:24 +0000 (02:44 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 12 Jul 2021 23:44:24 +0000 (02:44 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kioslave/mtp/devicecache.cpp
kioslave/mtp/kio_mtp.cpp

index 1ab946f..cf0f56f 100644 (file)
@@ -68,7 +68,6 @@ LIBMTP_mtpdevice_t* CachedDevice::getDevice()
         kDebug(KIO_MTP) << "reopen mtpdevice if we have no storage found";
         LIBMTP_Release_Device(mtpdevice);
         mtpdevice = LIBMTP_Open_Raw_Device_Uncached(&rawdevice);
-        resetDeviceStack(mtpdevice);
     }
     return mtpdevice;
 }
@@ -138,12 +137,14 @@ void DeviceCache::checkDevice(Solid::Device solidDevice)
                     LIBMTP_raw_device_t* rawDevice = &rawdevices[i];
 
                     LIBMTP_mtpdevice_t *mtpDevice = LIBMTP_Open_Raw_Device_Uncached(rawDevice);
-                    resetDeviceStack(mtpDevice);
+                    if (mtpDevice == NULL) {
+                        continue;
+                    }
                     const char* rawDeviceSerial = LIBMTP_Get_Serialnumber(mtpDevice);
 
                     kDebug(KIO_MTP) << "Checking for device match" << solidSerial << rawDeviceSerial;
                     if (solidSerial == rawDeviceSerial) {
-                        kDebug( KIO_MTP ) << "Found device matching the Solid description";
+                        kDebug(KIO_MTP) << "Found device matching the Solid description";
                     } else {
                         LIBMTP_Release_Device(mtpDevice);
                         continue;
@@ -163,6 +164,11 @@ void DeviceCache::checkDevice(Solid::Device solidDevice)
                 break;
             }
         }
+
+        if (!udiCache.contains(solidDevice.udi())) {
+            kError(KIO_MTP) << "No device match found, device busy?";
+        }
+
         ::free(rawdevices);
     }
 }
index 9f5bc9b..b8d8b2a 100644 (file)
@@ -784,7 +784,6 @@ void MTPSlave::mkdir(const KUrl& url, int)
                 kDebug(KIO_MTP) << "Attempting to create folder" << dirName;
 
                 ret = LIBMTP_Create_Folder(device, dirName, file->item_id, file->storage_id);
-               
             }
         }
         if (ret != 0) {