* [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel()
@ 2014-04-10 18:31 Christian Engelmayer
[not found] ` <CAJUuVQ5KW3v0DgwotDMow=rBvxoZKfYYD2misXbsMD6c1UaShw@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Christian Engelmayer @ 2014-04-10 18:31 UTC (permalink / raw)
To: linville, fariyaf
Cc: dan.carpenter, joe, linux-wireless, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1907 bytes --]
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.
Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
---
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(-)
diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 2361a68..be5b1fd 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -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);
--
1.8.3.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <CAJUuVQ5KW3v0DgwotDMow=rBvxoZKfYYD2misXbsMD6c1UaShw@mail.gmail.com>]
* Re: [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel() [not found] ` <CAJUuVQ5KW3v0DgwotDMow=rBvxoZKfYYD2misXbsMD6c1UaShw@mail.gmail.com> @ 2014-04-10 19:54 ` Greg Kroah-Hartman 2014-04-10 20:01 ` Andev 0 siblings, 1 reply; 5+ messages in thread From: Greg Kroah-Hartman @ 2014-04-10 19:54 UTC (permalink / raw) To: Andev Cc: Christian Engelmayer, linville, fariyaf, dan.carpenter, joe, linux-wireless, netdev, LKML On Thu, Apr 10, 2014 at 03:46:12PM -0400, Andev wrote: > Adding Greg KH, Why do I care about this? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel() 2014-04-10 19:54 ` Greg Kroah-Hartman @ 2014-04-10 20:01 ` Andev 2014-04-10 20:07 ` Dan Carpenter 2014-04-10 20:13 ` Christian Engelmayer 0 siblings, 2 replies; 5+ messages in thread From: Andev @ 2014-04-10 20:01 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Christian Engelmayer, linville, fariyaf, dan.carpenter, joe, linux-wireless, netdev, LKML On Thu, Apr 10, 2014 at 3:54 PM, Greg Kroah-Hartman <greg@kroah.com> wrote: > On Thu, Apr 10, 2014 at 03:46:12PM -0400, Andev wrote: >> 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@? -- Pratapa Rudra ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel() 2014-04-10 20:01 ` Andev @ 2014-04-10 20:07 ` Dan Carpenter 2014-04-10 20:13 ` Christian Engelmayer 1 sibling, 0 replies; 5+ messages in thread From: Dan Carpenter @ 2014-04-10 20:07 UTC (permalink / raw) To: Andev Cc: Greg Kroah-Hartman, Christian Engelmayer, linville, fariyaf, joe, linux-wireless, netdev, LKML On Thu, Apr 10, 2014 at 04:01:35PM -0400, Andev wrote: > On Thu, Apr 10, 2014 at 3:54 PM, Greg Kroah-Hartman <greg@kroah.com> wrote: > > On Thu, Apr 10, 2014 at 03:46:12PM -0400, Andev wrote: > >> 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel() 2014-04-10 20:01 ` Andev 2014-04-10 20:07 ` Dan Carpenter @ 2014-04-10 20:13 ` Christian Engelmayer 1 sibling, 0 replies; 5+ messages in thread From: Christian Engelmayer @ 2014-04-10 20:13 UTC (permalink / raw) To: Andev Cc: Greg Kroah-Hartman, linville, fariyaf, dan.carpenter, joe, linux-wireless, netdev, LKML [-- Attachment #1: Type: text/plain, Size: 564 bytes --] On Thu, 10 Apr 2014 16:01:35 -0400, Andev <debiandev@gmail.com> wrote: > On Thu, Apr 10, 2014 at 3:54 PM, Greg Kroah-Hartman <greg@kroah.com> wrote: > > On Thu, Apr 10, 2014 at 03:46:12PM -0400, Andev wrote: > >> 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-10 20:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10 18:31 [PATCH resend] rsi: Fix a potential memory leak in rsi_set_channel() Christian Engelmayer
[not found] ` <CAJUuVQ5KW3v0DgwotDMow=rBvxoZKfYYD2misXbsMD6c1UaShw@mail.gmail.com>
2014-04-10 19:54 ` Greg Kroah-Hartman
2014-04-10 20:01 ` Andev
2014-04-10 20:07 ` Dan Carpenter
2014-04-10 20:13 ` Christian Engelmayer
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).