Re: [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
From: Paul Moore <paul@paul-moore.com>
Date: 2015-02-01 02:40:54
Also in:
kernel-janitors, netdev
On Sat, Jan 31, 2015 at 4:38 PM, SF Markus Elfring [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Markus Elfring <redacted> Date: Sat, 31 Jan 2015 21:55:48 +0100 The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases by the netlbl_mgmt_add_common() function during error handling even if the passed variables contained still a null pointer. * This implementation detail could be improved by adjustments for jump labels. * Let us return immediately after the first failed function call according to the current Linux coding style convention. * Let us delete also an unnecessary check for the variable "entry" there. Signed-off-by: Markus Elfring <redacted> --- net/netlabel/netlabel_mgmt.c | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-)diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c index f5807f5..17f1ed5 100644 --- a/net/netlabel/netlabel_mgmt.c +++ b/net/netlabel/netlabel_mgmt.c
...
quoted hunk ↗ jump to hunk
@@ -237,15 +235,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info, ret_val = netlbl_domhsh_add(entry, audit_info); if (ret_val != 0) - goto add_failure; + goto free_address_map; return 0; -add_failure: - cipso_v4_doi_putdef(cipsov4); - if (entry) - kfree(entry->domain); +free_address_map: kfree(addrmap); +doi_put_def: + cipso_v4_doi_putdef(cipsov4); +free_domain: + kfree(entry->domain); +free_entry: kfree(entry); return ret_val; }
It would be nice if you could stick with the goto label naming style in the rest of the file, e.g. "add_free_addrmap"/"add_put_doi_def"/"add_free_domain"/"add_free_entry". -- paul moore www.paul-moore.com