D28535: [KIO-MTP] Fix null pointer dereference

Alexander Saoutkin noreply at phabricator.kde.org
Fri Apr 3 14:16:47 BST 2020


feverfew added a comment.


  If you want to, feel free, I'm a bit tight on time. But I will say this. the whole `getDevice()` function confuses me. I'm not entirely sure why this `if` check is necessary at all. The lifetime of devices and its children (i.e storage) should be managed by the KMTPD daemon AFAICT. A device shouldn't be trying to re-open itself anywhere IMO. To me the getDevice() function should simply be a simple return to avoid this NULL issue happening. Even if a device doesn't exist anymore, no segfaults should happen when passing an "invalid" `LIBMTP_device_T` to any other `LIBMTP` function?
  
  So to be succinct, the only correct fix here is to change `getDevice()` to `return m_mtpdevice`?

REPOSITORY
  R320 KIO Extras

REVISION DETAIL
  https://phabricator.kde.org/D28535

To: feverfew, akrutzler, dfaure, elvisangelaccio
Cc: anthonyfieroni, kde-frameworks-devel, fvogt, kfm-devel, ngraham, nikolaik, pberestov, iasensio, fprice, LeGast00n, cblack, fbampaloukas, alexde, GB_2, Codezela, feverfew, meven, michaelh, spoorun, navarromorales, firef, andrebarros, bruns, emmanuelp, mikesomov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200403/775b39e9/attachment.html>


More information about the Kde-frameworks-devel mailing list