Browse code

ctl: free send_buf in case of error

- disabled unused function

(cherry picked from commit 3bb1a30dda3b40ba2f188a4baab94ebda41f4a74)

Daniel-Constantin Mierla authored on 07/04/2021 08:08:56
Showing 1 changed files
... ...
@@ -223,7 +223,7 @@ static struct rpc_struct_l* grow_rpc_struct(struct rpc_struct_l *rs)
223 223
 #endif
224 224
 
225 225
 
226
-
226
+#if 0
227 227
 /* appends buf to an already init. binrpc_pkt */
228 228
 inline static int append_pkt_body(struct binrpc_pkt* p, unsigned char* buf,
229 229
 							int len)
... ...
@@ -247,7 +247,7 @@ inline static int append_pkt_body(struct binrpc_pkt* p, unsigned char* buf,
247 247
 error:
248 248
 	return -1; /* buff. overflow */
249 249
 }
250
-
250
+#endif
251 251
 
252 252
 
253 253
 inline static int append_iovec(struct iovec_array* a, unsigned char* buf,
... ...
@@ -379,6 +379,9 @@ inline static int init_binrpc_ctx(	struct binrpc_ctx* ctx,
379 379
 	}
380 380
 	/* we'll keep only the body */
381 381
 	err=binrpc_init_pkt(&ctx->out.pkt, send_buf, send_buf_len);
382
+	if(err!=0) {
383
+		ctl_free(send_buf);
384
+	}
382 385
 end:
383 386
 	return err;
384 387
 }