From: Rebecca Mckeever Date: Sat, 16 Apr 2022 10:24:34 +0000 (-0500) Subject: staging: rtl8192u: compare strcmp result to zero X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bb5369edbab8363a8a9a0c9ba59cb85020accb68;p=linux.git staging: rtl8192u: compare strcmp result to zero Add " == 0" to the condition in both else if branches to address a possible bug. strcmp returns 0 when its arguments are equal, which evaluates to false, often leading to errors when used in if statements. Currently, the statement in the first else if branch does not execute when its arguments are equal, but it does execute when crypt->ops->name equals any string other than "WEP" or "TKIP". Similarly, the second else if branch does not execute when its arguments are equal, and it only executes when crypt->ops->name equals "TKIP". The else branch never executes. It is unlikely that this is working as intended. Reviewed-by: Dan Carpenter Signed-off-by: Rebecca Mckeever Link: https://lore.kernel.org/r/20220416102434.97567-1-remckee0@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 9885917b91996..d6829cf6f7e3d 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -688,9 +688,9 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, } else { if (strcmp(crypt->ops->name, "WEP") == 0) ext->alg = IW_ENCODE_ALG_WEP; - else if (strcmp(crypt->ops->name, "TKIP")) + else if (strcmp(crypt->ops->name, "TKIP") == 0) ext->alg = IW_ENCODE_ALG_TKIP; - else if (strcmp(crypt->ops->name, "CCMP")) + else if (strcmp(crypt->ops->name, "CCMP") == 0) ext->alg = IW_ENCODE_ALG_CCMP; else return -EINVAL;