Thread (11 messages) 11 messages, 2 authors, 2025-09-26

Re: [PATCH net-next v3 4/5] bnxt_fwctl: Add bnxt fwctl device

From: Dave Jiang <dave.jiang@intel.com>
Date: 2025-09-26 17:24:36


On 9/26/25 10:11 AM, Pavan Chebbi wrote:
On Fri, Sep 26, 2025 at 9:31 PM Dave Jiang [off-list ref] wrote:
quoted
quoted
quoted
+     if (msg->num_dma) {
+             if (msg->num_dma > MAX_NUM_DMA_INDICATIONS) {
+                     dev_err(dev, "DMA buffers exceed the number supported\n");
+                     err = -EINVAL;
+                     goto free_msg_out;
Shouldn't rpc_in.resp get freed with an error returned? It's leaking rpc_in.resp on all the error paths from this point onward.

DJ
Isn't the caller taking care of it? The fw_rpc is called as:
void *outbuf __free(kvfree) = fwctl->ops->fw_rpc()
I was expecting that outbuf will be freed once it goes out of scope,
regardless of success or error?
Not exactly. Because when the function errors, it is returning ERR_PTR(rc) rather than rpc_in.resp. So the caller can't really free it because it doesn't have the pointer to the buffer. And even for the sake of argument lets say it works that way, it's best practice to clean up in the function on error paths rather than expecting the caller to do it for you. 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help