diff --git a/mtp/kiod_module/mtpstorage.cpp b/mtp/kiod_module/mtpstorage.cpp --- a/mtp/kiod_module/mtpstorage.cpp +++ b/mtp/kiod_module/mtpstorage.cpp @@ -308,8 +308,14 @@ void MTPStorage::updateStorageInfo() { - if (!LIBMTP_Get_Storage(getDevice(), LIBMTP_STORAGE_SORTBY_NOTSORTED)) { - for (const LIBMTP_devicestorage_t *storage = getDevice()->storage; storage != nullptr; storage = storage->next) { + LIBMTP_mtpdevice_t * device = getDevice(); + if (!device) { + qCDebug(LOG_KIOD_KMTPD) << "device doesn't exist, storage info not updated"; + return; + } + + if (!LIBMTP_Get_Storage(device, LIBMTP_STORAGE_SORTBY_NOTSORTED)) { + for (const LIBMTP_devicestorage_t *storage = device->storage; storage != nullptr; storage = storage->next) { if (m_id == storage->id) { qCDebug(LOG_KIOD_KMTPD) << "storage info updated"; setStorageProperties(storage);