Fix oal_bt_deinit crash issue
[platform/core/connectivity/bluetooth-frwk.git] / bt-otp / bt-otpserver.c
index 80348d1..f44f487 100644 (file)
@@ -815,6 +815,9 @@ fail:
                                _bt_otp_start_write_on_fd();
                        else if (oacp_op->opcode == OACP_WRITE)
                                _bt_otp_start_read_on_fd();
+               } else {
+                       /* Close fd if oacp_op is NULL */
+                       close(fd);
                }
                g_dbus_method_invocation_return_value(invocation, NULL);
        }
@@ -1820,6 +1823,9 @@ int _bt_otp_read_cb(const char *obj_path, char **value, int *len, uint16_t offse
 
                *len = info->value_length - offset;
                *value = (char *)malloc(sizeof(char)*(*len));
+               if (*value == NULL)
+                       return BLUETOOTH_ATT_ERROR_INTERNAL;
+
                memcpy(*value, info->char_value, *len);
 
                return BLUETOOTH_ATT_ERROR_NONE;