diff --git a/usb/gadget/aidl/default/UsbGadget.cpp b/usb/gadget/aidl/default/UsbGadget.cpp index c4986e8e18..4a406528f7 100644 --- a/usb/gadget/aidl/default/UsbGadget.cpp +++ b/usb/gadget/aidl/default/UsbGadget.cpp @@ -90,8 +90,11 @@ void currentFunctionsAppliedCallback(bool functionsApplied, void *payload) { gadget->mCurrentUsbFunctionsApplied = functionsApplied; } -ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr &callback, - int64_t in_transactionId) { +ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr& callback, + int64_t in_transactionId) { + if (callback == nullptr) { + return ScopedAStatus::fromExceptionCode(EX_NULL_POINTER); + } ScopedAStatus ret = callback->getCurrentUsbFunctionsCb( mCurrentUsbFunctions, mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED,