Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa17f09b authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Ensure that 'opChanged' can access a valid device instance

'opChanged' callbacks will get registered before the camera3
device initialization. They are not synchronized with the
main service lock and can potentially try to access an invalid
device reference.
Ensure that the 'opChanged' callback registration always happens
after the camera3 device initialization.

Bug: 240725858
Test: Camera CTS
Change-Id: Id3d9877dfafc894cceca5358213f39d5b46a7aee
parent ebba6f05
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -105,11 +105,6 @@ status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr
          TClientBase::mCameraIdStr.string());
    status_t res;

    // Verify ops permissions
    res = TClientBase::startCameraOps();
    if (res != OK) {
        return res;
    }
    IPCTransport providerTransport = IPCTransport::INVALID;
    res = providerPtr->getCameraIdIPCTransport(TClientBase::mCameraIdStr.string(),
            &providerTransport);
@@ -145,6 +140,14 @@ status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr
        return res;
    }

    // Verify ops permissions
    res = TClientBase::startCameraOps();
    if (res != OK) {
        TClientBase::finishCameraOps();
        mDevice.clear();
        return res;
    }

    wp<NotificationListener> weakThis(this);
    res = mDevice->setNotifyCallback(weakThis);
    if (res != OK) {