Skip to content
Commit 6010d092 authored by Jaime Torres Amate's avatar Jaime Torres Amate Committed by Elvis Angelaccio
Browse files

Avoid a kio-mtp crash when trying to add a blocked device to the device cache

Summary:
When the device is blocked, for example by amarok mtp plugin, the result of LIBMTP_Open_Raw_Device_Uncached(rawDevice) is nullptr and
LIBMTP_Get_Friendlyname(nullptr) crashes.

Avoid to create a cache for a device that can't be opened.

CCBUG: 396527

Test Plan:
With Amarok started and its mtp plugin enabled, plug in an android device.
Try to open it with dolphin, always the same kio backtrace:

```
==13233== Invalid read of size 8
==13233==    at 0x1087ABCE: LIBMTP_Get_Friendlyname (in /usr/lib64/libmtp.so.9.4.0)
==13233==    by 0x105EE67C: CachedDevice::CachedDevice(LIBMTP_mtpdevice_struct*, LIBMTP_raw_device_struct*, QString, int) (devicecache.cpp:44)
==13233==    by 0x105F0A30: DeviceCache::checkDevice(Solid::Device) (devicecache.cpp:150)
==13233==    by 0x105F1517: DeviceCache::DeviceCache(int, QObject*) (devicecache.cpp:94)
==13233==    by 0x105F2FC1: MTPSlave::MTPSlave(QByteArray const&, QByteArray const&) (kio_mtp.cpp:70)
==13233==    by 0x105F8BF9: kdemain (kio_mtp.cpp:54)
==13233==    by 0x4016CC: main (kioslave.cpp:130)
==13233==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
```
And in dolphin, the message: MTP died unexpectedly

After, the message: The file or folder udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1 does not exist.

Reviewers: #frameworks, elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: broulik

Differential Revision: https://phabricator.kde.org/D14158
parent 9b368c39
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment