Browse Source

cpg: Handle ipc error in cpg_zcb_alloc/free

- Error returned by coroipcc_msg_send_reply_receive is now correctly
  handled.
- If munmap fails, error is set to proper value and handle is put back
  into handle_db

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 10 years ago
parent
commit
3f51b169f5
1 changed files with 14 additions and 4 deletions
  1. 14 4
      lib/cpg.c

+ 14 - 4
lib/cpg.c

@@ -928,13 +928,16 @@ cs_error_t cpg_zcb_alloc (
 		&res_coroipcs_zc_alloc,
 		sizeof (struct qb_ipc_response_header));
 
+	if (error != CS_OK) {
+		goto error_exit;
+	}
+
 	hdr = (struct coroipcs_zc_header *)buf;
 	hdr->map_size = map_size;
-	*buffer = ((char *)buf) + sizeof (struct coroipcs_zc_header);
+	*buffer = ((char *)buf) + sizeof (struct coroipcs_zc_header) + sizeof (struct req_lib_cpg_mcast);
 
+error_exit:
 	hdb_handle_put (&cpg_handle_t_db, handle);
-	*buffer = ((char *)*buffer) + sizeof (struct req_lib_cpg_mcast);
-
 	return (error);
 }
 
@@ -970,11 +973,18 @@ cs_error_t cpg_zcb_free (
 		&res_coroipcs_zc_free,
 		sizeof (struct qb_ipc_response_header));
 
+	if (error != CS_OK) {
+		goto error_exit;
+	}
+
 	res = munmap ((void *)header, header->map_size);
 	if (res == -1) {
-			return (-1);
+		error = qb_to_cs_error(-errno);
+
+		goto error_exit;
 	}
 
+error_exit:
 	hdb_handle_put (&cpg_handle_t_db, handle);
 
 	return (error);