* [PATCH] wireless: remove unnecessary condition check before kfree
@ 2018-09-08 14:12 zhong jiang
2018-09-10 7:10 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: zhong jiang @ 2018-09-08 14:12 UTC (permalink / raw)
To: davem, johannes; +Cc: linux-wireless, netdev, linux-kernel
kfree has taken the null pointer into account. Just remove the
redundant condition check before kfree.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
net/wireless/reg.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 5ad5b9f..dc87e3d 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1086,7 +1086,7 @@ int reg_reload_regdb(void)
}
rtnl_lock();
- if (!IS_ERR_OR_NULL(regdb))
+ if (!IS_ERR(regdb))
kfree(regdb);
regdb = db;
rtnl_unlock();
@@ -3920,7 +3920,7 @@ void regulatory_exit(void)
kfree(reg_request);
}
- if (!IS_ERR_OR_NULL(regdb))
+ if (!IS_ERR(regdb))
kfree(regdb);
free_regdb_keyring();
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wireless: remove unnecessary condition check before kfree
2018-09-08 14:12 [PATCH] wireless: remove unnecessary condition check before kfree zhong jiang
@ 2018-09-10 7:10 ` Johannes Berg
2018-09-10 13:54 ` zhong jiang
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2018-09-10 7:10 UTC (permalink / raw)
To: zhong jiang, davem; +Cc: linux-wireless, netdev, linux-kernel
On Sat, 2018-09-08 at 22:12 +0800, zhong jiang wrote:
> kfree has taken the null pointer into account. Just remove the
> redundant condition check before kfree.
I'm all for doing that if it actually removes conditionals, but
> - if (!IS_ERR_OR_NULL(regdb))
> + if (!IS_ERR(regdb))
> kfree(regdb);
this seems rather pointless since there's still a condition. In that
case, I feel it's easier to understand the original code.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wireless: remove unnecessary condition check before kfree
2018-09-10 7:10 ` Johannes Berg
@ 2018-09-10 13:54 ` zhong jiang
0 siblings, 0 replies; 3+ messages in thread
From: zhong jiang @ 2018-09-10 13:54 UTC (permalink / raw)
To: Johannes Berg; +Cc: davem, linux-wireless, netdev, linux-kernel
On 2018/9/10 15:10, Johannes Berg wrote:
> On Sat, 2018-09-08 at 22:12 +0800, zhong jiang wrote:
>> kfree has taken the null pointer into account. Just remove the
>> redundant condition check before kfree.
> I'm all for doing that if it actually removes conditionals, but
>
>> - if (!IS_ERR_OR_NULL(regdb))
>> + if (!IS_ERR(regdb))
>> kfree(regdb);
> this seems rather pointless since there's still a condition. In that
> case, I feel it's easier to understand the original code.
Fine, make sense you have said. I just consider the duplication of function.
Thanks,
zhong jiang
> johannes
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-10 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-08 14:12 [PATCH] wireless: remove unnecessary condition check before kfree zhong jiang
2018-09-10 7:10 ` Johannes Berg
2018-09-10 13:54 ` zhong jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).