rsi: Fix a potential memory leak in rsi_set_channel()
Subsystems (3)
PATCH RESEND 1/1 rsi: Fix a potential memory leak in rsi_set_channel()
Fix a potential memory leak in function rsi_set_channel() that is used to program channel changes. The channel check block for the frequency bands directly exits the function in case of an error, thus leaving an already allocated skb unreferenced. Move the checks above allocating the skb. Detected by Coverity: CID 1195576.
---
Applies against git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git Compile tested.
--- drivers/net/wireless/rsi/rsi_91x_mgmt.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/wireless/rsi/rsi_91x_mgmt.c +10 -10
@@ -841,16 +841,6 @@ int rsi_set_channel(struct rsi_common *common, u16 channel)rsi_dbg (MGMT_TX_ZONE ,"%s: Sending scan req frame\n" , __func__); - skb =dev_alloc_skb (FRAME_DESC_SZ ); -if (!skb) { -rsi_dbg (ERR_ZONE ,"%s: Failed in allocation of skb\n" , - __func__); -return -ENOMEM ; - } - -memset (skb->data,0 ,FRAME_DESC_SZ ); - mgmt_frame = (struct rsi_mac_frame *)skb->data; -if (common->band ==IEEE80211_BAND_5GHZ ) {if ((channel >=36 ) && (channel <=64 )) channel = ((channel -32 ) /4 );
@@ -868,6 +858,16 @@ int rsi_set_channel(struct rsi_common *common, u16 channel) } } + skb =dev_alloc_skb (FRAME_DESC_SZ ); +if (!skb) { +rsi_dbg (ERR_ZONE ,"%s: Failed in allocation of skb\n" , + __func__); +return -ENOMEM ; + } + +memset (skb->data,0 ,FRAME_DESC_SZ ); + mgmt_frame = (struct rsi_mac_frame *)skb->data; + mgmt_frame->desc_word[0 ] =cpu_to_le16 (RSI_WIFI_MGMT_Q <<12 ); mgmt_frame->desc_word[1 ] =cpu_to_le16 (SCAN_REQUEST ); mgmt_frame->desc_word[4 ] =cpu_to_le16 (channel);
Signature · 1 line
1.8.3.2
Quoted 1 line · Andev
Adding Greg KH,
Why do I care about this?
Quoted 5 lines · Greg Kroah-Hartman
Quoted 1 line · Andev
Adding Greg KH,
Why do I care about this?
I am not sure if this needs to be applied to stable too. Should I have cc'ed stable@?
Signature · 1 line
Pratapa Rudra
Quoted 9 lines · Andev
Quoted 5 lines · Greg Kroah-Hartman
Quoted 1 line · Andev
Adding Greg KH,
Why do I care about this?
I am not sure if this needs to be applied to stable too. Should I have cc'ed stable@?
Read Documentation/stable_kernel_rules.txt.
But for netdev, then Dave M. maintains a queue of patches which go to stable. So this would go through Dave's stable queue and he forwards them to Greg.
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Andev
Quoted 5 lines · Greg Kroah-Hartman
Quoted 1 line · Andev
Adding Greg KH,
Why do I care about this?
I am not sure if this needs to be applied to stable too. Should I have cc'ed stable@?
Besides what Dan pointed out, this driver has just been pulled recently and afaik is not included in v3.14. see http://www.spinics.net/lists/netdev/msg276519.html
Regards,
Christian