<table><tr><td style="">jtamate created this revision.<br />jtamate added a reviewer: Frameworks.<br />jtamate requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D14158">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>When the device is blocked, for example by amarok mtp plugin, the result of LIBMTP_Open_Raw_Device_Uncached(rawDevice) is nullptr and <br />
LIBMTP_Get_Friendlyname(nullptr) crashes.</p>
<p>Avoid to create a cache for a device that can't be opened.</p>
<p>CCBUG: 396527</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>With Amarok started and its mtp plugin enabled, plug in an android device.<br />
Try to open it with dolphin, always the same kio backtrace:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">==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</pre></div>
<p>And in dolphin, the message: MTP died unexpectedly</p>
<p>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.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R320 KIO Extras</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14158">https://phabricator.kde.org/D14158</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>mtp/devicecache.cpp</div></div></div><br /><div><strong>To: </strong>jtamate, Frameworks<br /></div>