sdm: Fix memory leaks.

- Fix memory leaks.
- Remove memcpy usage.

Change-Id: I63ed7e86d5a5e68fd90820705486897d3e8bd88e
diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp
index 2aa4a31..952952d 100644
--- a/libqdutils/qdMetaData.cpp
+++ b/libqdutils/qdMetaData.cpp
@@ -61,7 +61,7 @@
     data->operation |= paramType;
     switch (paramType) {
         case PP_PARAM_HSIC:
-            memcpy((void *)&data->hsicData, param, sizeof(HSICData_t));
+            data->hsicData = *((HSICData_t *)param);
             break;
         case PP_PARAM_SHARPNESS:
             data->sharpness = *((int32_t *)param);
@@ -76,13 +76,13 @@
             memcpy((void *)&data->igcData, param, sizeof(IGCData_t));
             break;
         case PP_PARAM_SHARP2:
-            memcpy((void *)&data->Sharp2Data, param, sizeof(Sharp2Data_t));
+            data->Sharp2Data = *((Sharp2Data_t *)param);
             break;
         case PP_PARAM_TIMESTAMP:
             data->timestamp = *((int64_t *)param);
             break;
         case UPDATE_BUFFER_GEOMETRY:
-            memcpy((void *)&data->bufferDim, param, sizeof(BufferDim_t));
+            data->bufferDim = *((BufferDim_t *)param);
             break;
         case UPDATE_REFRESH_RATE:
             data->refreshrate = *((uint32_t *)param);
diff --git a/sdm/libs/core/comp_manager.h b/sdm/libs/core/comp_manager.h
index f8175f3..1d0b5e8 100644
--- a/sdm/libs/core/comp_manager.h
+++ b/sdm/libs/core/comp_manager.h
@@ -89,8 +89,8 @@
   Locker locker_;
   ResourceInterface *resource_intf_ = NULL;
   ResourceDefault resource_default_;
-  uint64_t registered_displays_ = 0;    // Stores the bit mask of registered displays
-  uint64_t configured_displays_ = 0;    // Stores the bit mask of sucessfully configured displays
+  uint32_t registered_displays_ = 0;    // Stores the bit mask of registered displays
+  uint32_t configured_displays_ = 0;    // Stores the bit mask of sucessfully configured displays
   bool safe_mode_ = false;              // Flag to notify all displays to be in resource crunch
                                         // mode, where strategy manager chooses the best strategy
                                         // that uses optimal number of pipes for each display
diff --git a/sdm/libs/hwc/hwc_buffer_allocator.cpp b/sdm/libs/hwc/hwc_buffer_allocator.cpp
index 54dbefb..556780f 100644
--- a/sdm/libs/hwc/hwc_buffer_allocator.cpp
+++ b/sdm/libs/hwc/hwc_buffer_allocator.cpp
@@ -78,6 +78,7 @@
 
   error = SetBufferInfo(buffer_config.format, &format, &alloc_flags);
   if (error != 0) {
+    delete meta_buffer_info;
     return kErrorParameters;
   }
 
@@ -96,6 +97,7 @@
   error = alloc_controller_->allocate(data, alloc_flags);
   if (error != 0) {
     DLOGE("Error allocating memory size %d uncached %d", data.size, data.uncached);
+    delete meta_buffer_info;
     return kErrorMemory;
   }
 
diff --git a/sdm/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp
index 10a8ec2..c6b8dad 100644
--- a/sdm/libs/hwc/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -79,6 +79,7 @@
 
   status = hwc_display_virtual->SetOutputSliceFromMetadata(content_list);
   if (status) {
+    Destroy(hwc_display_virtual);
     return status;
   }
 
diff --git a/sdm/libs/hwc/hwc_session.cpp b/sdm/libs/hwc/hwc_session.cpp
index 8fccf64..28ffa65 100644
--- a/sdm/libs/hwc/hwc_session.cpp
+++ b/sdm/libs/hwc/hwc_session.cpp
@@ -628,7 +628,7 @@
     // Read backlight and store it internally. Set backlight to 0 on primary.
     if (read(fd, brightness_, sizeof(brightness_)) > 0) {
       DLOGI("backlight brightness is %s", brightness_);
-      ssize_t ret = write(fd, bl_brightness, sizeof(bl_brightness));
+      ssize_t ret = write(fd, bl_brightness, strlen(bl_brightness));
       if (ret < 0) {
         DLOGE("Failed to write backlight node err = %d errstr = %s", errno, strerror(errno));
         close(fd);