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-09 17:35:56 -0800 |
commit | d726faae5a8ff642b35a16cef4aa603d5c997990 (patch) | |
tree | af683c1adfbb6fd411e92c8fddb89c40c94fe94a | |
parent | 33a9d95f695d04c61480abc2ea02bc2754c26148 (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); |