From 9b1300716414d770496452a5ff14c85f15f58cfc Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Wed, 1 Feb 2023 23:38:37 +0000 Subject: [PATCH] Fixing null deference in android.hardware.usb.gadget-service.example Test: atest VtsAidlUsbTargetTest Bug: 267534245 Change-Id: Ib28b7848205809912b6789d0e050c1a981dc1ce8 Merged-In: Ib28b7848205809912b6789d0e050c1a981dc1ce8 --- usb/gadget/aidl/default/UsbGadget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usb/gadget/aidl/default/UsbGadget.cpp b/usb/gadget/aidl/default/UsbGadget.cpp index 72cf681e5d..51f7f5b817 100644 --- a/usb/gadget/aidl/default/UsbGadget.cpp +++ b/usb/gadget/aidl/default/UsbGadget.cpp @@ -91,6 +91,9 @@ void currentFunctionsAppliedCallback(bool functionsApplied, void* payload) { 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,