diff mbox

[2/2] rtlwifi: silence underflow warning

Message ID 20170929075234.dgyuiwbowu3jq6r4@mwanda (mailing list archive)
State Accepted
Commit 64e79426c2041b931c053a11743277a4f7f279c4
Delegated to: Kalle Valo
Headers show

Commit Message

Dan Carpenter Sept. 29, 2017, 7:52 a.m. UTC
My static checker complains that we have an upper bound but no lower
bound.  I suspect neither are really required but it doesn't hurt to add
a check for negatives.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Kalle Valo Oct. 10, 2017, 8:20 a.m. UTC | #1
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> My static checker complains that we have an upper bound but no lower
> bound.  I suspect neither are really required but it doesn't hurt to add
> a check for negatives.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
> index c53cbf3d52bd..294a6b43d1bc 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/core.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/core.c
> @@ -453,7 +453,8 @@ static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
>  	for (i = 0; i < wow->n_patterns; i++) {
>  		memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
>  		memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
> -		if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
> +		if (patterns[i].pattern_len < 0 ||
> +		    patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
>  			RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
>  				 "Pattern[%d] is too long\n", i);
>  			continue;

Patch applied to wireless-drivers-next.git, thanks.

64e79426c204 rtlwifi: silence underflow warning
diff mbox

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index c53cbf3d52bd..294a6b43d1bc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -453,7 +453,8 @@  static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
 	for (i = 0; i < wow->n_patterns; i++) {
 		memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
 		memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
-		if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
+		if (patterns[i].pattern_len < 0 ||
+		    patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
 			RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
 				 "Pattern[%d] is too long\n", i);
 			continue;