diff options
author | Jack Pham <quic_jackp@quicinc.com> | 2022-10-17 00:17:50 -0700 |
---|---|---|
committer | Jack Pham <quic_jackp@quicinc.com> | 2023-02-15 07:44:29 +0000 |
commit | ac3fe1c45df579fd3e2adf6bcdf7ec35cf26d03d (patch) | |
tree | c0d241b614f653c140a9f69de86e23250e141824 | |
parent | f124ceb0d4bfe3975ce366951e142d849b675588 (diff) |
UsbGadgetHal: Add null check in getCurrentUsbFunctions()
Avoid dereferencing if the callback parameter is null.
Bug: 268085267
CRs-Fixed: 3313859
Change-Id: I9da79fd92f44abf0175e2ca311f0247b49bace1d
-rw-r--r-- | usb/gadget/1.1/default/UsbGadget.cpp | 2 | ||||
-rw-r--r-- | usb/gadget/1.2/default/UsbGadget.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/usb/gadget/1.1/default/UsbGadget.cpp b/usb/gadget/1.1/default/UsbGadget.cpp index 36d865dc2e..0d0b4032d4 100644 --- a/usb/gadget/1.1/default/UsbGadget.cpp +++ b/usb/gadget/1.1/default/UsbGadget.cpp @@ -46,6 +46,8 @@ void currentFunctionsAppliedCallback(bool functionsApplied, void* payload) { } Return<void> UsbGadget::getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback>& callback) { + if (!callback) return Void(); + Return<void> ret = callback->getCurrentUsbFunctionsCb( mCurrentUsbFunctions, mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED); diff --git a/usb/gadget/1.2/default/UsbGadget.cpp b/usb/gadget/1.2/default/UsbGadget.cpp index 8dd229e0fd..a59e983f69 100644 --- a/usb/gadget/1.2/default/UsbGadget.cpp +++ b/usb/gadget/1.2/default/UsbGadget.cpp @@ -46,6 +46,8 @@ void currentFunctionsAppliedCallback(bool functionsApplied, void* payload) { } Return<void> UsbGadget::getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback>& callback) { + if (!callback) return Void(); + Return<void> ret = callback->getCurrentUsbFunctionsCb( mCurrentUsbFunctions, mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED); |