lkml.org 
[lkml]   [2023]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] net: openvswitch: fix flow memory leak in ovs_flow_cmd_new
From
Date
On 2/1/23 6:45 PM, Simon Horman wrote:
> I see this would work by virtue of kfree(key) doing nothing
> of key is NULL, the error case in question. And that otherwise key is
> non-NULL if this path is hit.
>
> However, the idiomatic approach to error handling is for the error path
> to unwind resource allocations in the reverse order that they were made.
> And for goto labels to control how far to unwind.
>

You are right, thanks. Have to keep 'goto' structured, otherwise there
would be a 'goto' mess.

> So I think the following would be more in keeping with the intention of the
> code. Even if it is a somewhat more verbose change.
>
> *compile tested only!*

I'll test this on error paths and resend the patch.

\
 
 \ /
  Last update: 2023-03-27 00:06    [W:0.065 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site