diff --git a/libgralloc1/gr_device_impl.cpp b/libgralloc1/gr_device_impl.cpp index d421ff19..c900d23e 100644 --- a/libgralloc1/gr_device_impl.cpp +++ b/libgralloc1/gr_device_impl.cpp @@ -65,7 +65,7 @@ struct gralloc_module_t HAL_MODULE_INFO_SYM = { int gralloc_device_open(const struct hw_module_t *module, const char *name, hw_device_t **device) { int status = -EINVAL; - if (!strcmp(name, GRALLOC_HARDWARE_MODULE_ID)) { + if (module && device && !strcmp(name, GRALLOC_HARDWARE_MODULE_ID)) { gralloc1::GrallocImpl * /*gralloc1_device_t*/ dev = gralloc1::GrallocImpl::GetInstance(module); *device = reinterpret_cast(dev); if (dev) { @@ -105,7 +105,7 @@ int GrallocImpl::CloseDevice(hw_device_t *device __unused) { void GrallocImpl::GetCapabilities(struct gralloc1_device *device, uint32_t *out_count, int32_t /*gralloc1_capability_t*/ *out_capabilities) { - if (device != nullptr) { + if (device != nullptr && out_count != nullptr) { if (out_capabilities != nullptr && *out_count >= 3) { out_capabilities[0] = GRALLOC1_CAPABILITY_TEST_ALLOCATE; out_capabilities[1] = GRALLOC1_CAPABILITY_LAYERED_BUFFERS; @@ -178,7 +178,7 @@ gralloc1_function_pointer_t GrallocImpl::GetFunction(gralloc1_device_t *device, gralloc1_error_t GrallocImpl::Dump(gralloc1_device_t *device, uint32_t *out_size, char *out_buffer) { - if (!device) { + if (!device || !out_size) { ALOGE("Gralloc Error : device=%p", (void *)device); return GRALLOC1_ERROR_BAD_DESCRIPTOR; } @@ -213,7 +213,7 @@ gralloc1_error_t GrallocImpl::CheckDeviceAndHandle(gralloc1_device_t *device, gralloc1_error_t GrallocImpl::CreateBufferDescriptor(gralloc1_device_t *device, gralloc1_buffer_descriptor_t *out_descriptor) { - if (!device) { + if (!device || !out_descriptor) { return GRALLOC1_ERROR_BAD_DESCRIPTOR; } GrallocImpl const *dev = GRALLOC_IMPL(device);