hal: Fixes for the issues reported by KlocWork
-Fixes for KW issues reported which may cause NULL dereference:
283559, 293531, 293533, 309145
Change-Id: Ic0a1e891ba7a013ed48f1e5c82d4051f8e8b5a9d
diff --git a/hal/msm8916/hw_info.c b/hal/msm8916/hw_info.c
index ce508c1..689e834 100644
--- a/hal/msm8916/hw_info.c
+++ b/hal/msm8916/hw_info.c
@@ -226,6 +226,10 @@
struct hardware_info *hw_info;
hw_info = malloc(sizeof(struct hardware_info));
+ if (!hw_info) {
+ ALOGE("failed to allocate mem for hardware info");
+ return NULL;
+ }
if (strstr(snd_card_name, "msm8x16") || strstr(snd_card_name, "msm8939") ||
strstr(snd_card_name, "msm8909")) {
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 2046da7..00626f8 100755
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -694,6 +694,10 @@
static struct csd_data *open_csd_client()
{
struct csd_data *csd = calloc(1, sizeof(struct csd_data));
+ if (!csd) {
+ ALOGE("failed to allocate csd_data mem");
+ return NULL;
+ }
csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW);
if (csd->csd_client == NULL) {
@@ -961,6 +965,10 @@
char *cvd_version = NULL;
my_data = calloc(1, sizeof(struct platform_data));
+ if (!my_data) {
+ ALOGE("failed to allocate platform data");
+ return NULL;
+ }
while (snd_card_num < MAX_SND_CARD) {
adev->mixer = mixer_open(snd_card_num);