Skip to contentSkip to conversation

cfg80211: Remove unnecessary ksize() call

PATCH In review Michael Buesch 2 participants 2 messages Apr 25, 2009 – Apr 26, 2009 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfg80211: Remove unnecessary ksize() call

This removes an unnecessary ksize() call. krealloc() will do this test internally and won't perform any allocation if the space is already sufficient to hold the data.
So remove the redundant check.

---
 net/wireless/scan.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
net/wireless/scan.c +3 -5
@@ -384,11 +384,9 @@ cfg80211_bss_update(struct cfg80211_regi
 			} else {
 				u8 *ies = found->pub.information_elements;
 
-				if (found->ies_allocated) {
-					if (ksize(ies) < ielen)
-						ies = krealloc(ies, ielen,
-							       GFP_ATOMIC);
-				} else
+				if (found->ies_allocated)
+					ies = krealloc(ies, ielen, GFP_ATOMIC);
+				else
 					ies = kmalloc(ielen, GFP_ATOMIC);
 
 				if (ies) {
Signature · 1 line
Greetings, Michael.
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Michael Buesch

This removes an unnecessary ksize() call. krealloc() will do this test internally and won't perform any allocation if the space is already sufficient to hold the data.
So remove the redundant check.

Good catch, thanks.

johannes

Quoted 22 lines
---
 net/wireless/scan.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
net/wireless/scan.c +3 -5
@@ -384,11 +384,9 @@ cfg80211_bss_update(struct cfg80211_regi
 			} else {
 				u8 *ies = found->pub.information_elements;
 
-				if (found->ies_allocated) {
-					if (ksize(ies) < ielen)
-						ies = krealloc(ies, ielen,
-							       GFP_ATOMIC);
-				} else
+				if (found->ies_allocated)
+					ies = krealloc(ies, ielen, GFP_ATOMIC);
+				else
 					ies = kmalloc(ielen, GFP_ATOMIC);
 
 				if (ies) {