* [PATCH] cfg80211: delete redundant free code
@ 2021-11-15 9:21 liuguoqiang
2021-11-15 9:24 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: liuguoqiang @ 2021-11-15 9:21 UTC (permalink / raw)
To: johannes; +Cc: davem, kuba, linux-wireless, netdev, linux-kernel, liuguoqiang
When kzalloc failed and rdev->sacn_req or rdev->scan_msg is null, pass a
null pointer to kfree is redundant, delete it and return directly.
Signed-off-by: liuguoqiang <liuguoqiang@uniontech.com>
---
net/wireless/scan.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 22e92be61938..011fcfabc846 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -2702,10 +2702,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
if (IS_ERR(rdev))
return PTR_ERR(rdev);
- if (rdev->scan_req || rdev->scan_msg) {
- err = -EBUSY;
- goto out;
- }
+ if (rdev->scan_req || rdev->scan_msg)
+ return -EBUSY;
wiphy = &rdev->wiphy;
@@ -2718,10 +2716,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
n_channels * sizeof(void *),
GFP_ATOMIC);
- if (!creq) {
- err = -ENOMEM;
- goto out;
- }
+ if (!creq)
+ return -ENOMEM;
creq->wiphy = wiphy;
creq->wdev = dev->ieee80211_ptr;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cfg80211: delete redundant free code
2021-11-15 9:21 [PATCH] cfg80211: delete redundant free code liuguoqiang
@ 2021-11-15 9:24 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2021-11-15 9:24 UTC (permalink / raw)
To: liuguoqiang; +Cc: davem, kuba, linux-wireless, netdev, linux-kernel
On Mon, 2021-11-15 at 17:21 +0800, liuguoqiang wrote:
> When kzalloc failed and rdev->sacn_req or rdev->scan_msg is null, pass a
> null pointer to kfree is redundant, delete it and return directly.
>
Arguably then we should not set creq=NULL at the beginning?
johannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-15 9:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-15 9:21 [PATCH] cfg80211: delete redundant free code liuguoqiang
2021-11-15 9:24 ` Johannes Berg
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).