# RE: \[PATCH 2/2\] librdmacm: fix resource leaks when CMA\_CREATE\_MSG\_CMD\_RESP fails

- From: Hefty, Sean \<hidden\>
- Date: 2011-08-22 22:39:54 
- List: linux-rdma
- Page: https://ratatoskr.run/linux-rdma/2011/08/15416010
- Thread: https://ratatoskr.run/linux-rdma/2011/08/15416010/t.md

```text
> -#define CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \
> +#define CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size, clean_cmd) \

This starts to get ugly, especially with usage that ends up looking like this:

> -	CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_DESTROY_ID, size);
> +	CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_DESTROY_ID, size, );

I think a cleaner fix would be to replace CMA_CREATE_MSG_CMD_RESP and CMA_CREATE_MSG_CMD with macros that simply initialize structures and do not call return.  I'll update the code and either apply patch 1 or make sure that the necessary cleanup is added, depending on how the resulting code gets structured.

Does anyone know of any reason why we can't change the structures in rdma_cma_abi.h?  (Binary compatibility with the kernel would be preserved, obviously.)

Thanks,
Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
```
