hal: add checks for possible NULL dereferences in hal
Add checks for possible NULL dereferences in hal.
Change-Id: I56c9238eb7b686628c62c02e5ff635faabb1bd81
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 12bc76b..4ef9c00 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2794,6 +2794,10 @@
if (ret == 0) {
register_out_stream(out);
if (out->realtime) {
+ if (out->pcm == NULL || !pcm_is_ready(out->pcm)) {
+ ALOGE("%s: pcm stream not ready", __func__);
+ goto error_open;
+ }
ret = pcm_start(out->pcm);
if (ret < 0)
goto error_open;
@@ -4883,8 +4887,8 @@
struct stream_in *in = (struct stream_in *)stream;
struct audio_device *adev = in->dev;
int ret = 0;
- unsigned int offset1;
- unsigned int frames1;
+ unsigned int offset1 = 0;
+ unsigned int frames1 = 0;
const char *step = "";
pthread_mutex_lock(&adev->lock);