Message ID | 57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.git.sean.wang@mediatek.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Felix Fietkau |
Headers | show |
Series | [v2,1/3] mt76: mt7663u: fix memory leak in set key | expand |
> From: Sean Wang <sean.wang@mediatek.com> > > Fix memory leak in set key. > > v1 -> v2: > - remove unneeded kfree > > Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support") > Signed-off-by: Sean Wang <sean.wang@mediatek.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> > --- > .../net/wireless/mediatek/mt76/mt7615/usb.c | 21 ++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c > index 0ba28d37c414..f3c3ad3509c8 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c > @@ -165,12 +165,16 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, > > lockdep_assert_held(&dev->mt76.mutex); > > - if (!sta) > - return -EINVAL; > + if (!sta) { > + err = -EINVAL; > + goto out; > + } > > cipher = mt7615_mac_get_cipher(key->cipher); > - if (cipher == MT_CIPHER_NONE) > - return -EOPNOTSUPP; > + if (cipher == MT_CIPHER_NONE) { > + err = -EOPNOTSUPP; > + goto out; > + } > > wcid = &wd->sta->wcid; > > @@ -178,19 +182,22 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, > err = mt7615_mac_wtbl_update_key(dev, wcid, key->key, key->keylen, > cipher, key->cmd); > if (err < 0) > - return err; > + goto out; > > err = mt7615_mac_wtbl_update_pk(dev, wcid, cipher, key->keyidx, > key->cmd); > if (err < 0) > - return err; > + goto out; > > if (key->cmd == SET_KEY) > wcid->cipher |= BIT(cipher); > else > wcid->cipher &= ~BIT(cipher); > > - return 0; > +out: > + kfree(key->key); > + > + return err; > } > > void mt7663u_wtbl_work(struct work_struct *work) > -- > 2.25.1
On 2020-07-07 21:16, sean.wang@mediatek.com wrote: > From: Sean Wang <sean.wang@mediatek.com> > > Fix memory leak in set key. > > v1 -> v2: > - remove unneeded kfree > > Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support") > Signed-off-by: Sean Wang <sean.wang@mediatek.com> Next time, please move the changelog below the '---' line so that it doesn't end up in the patch description. I will fix it up locally in my tree. Thanks, - Felix
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c index 0ba28d37c414..f3c3ad3509c8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c @@ -165,12 +165,16 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, lockdep_assert_held(&dev->mt76.mutex); - if (!sta) - return -EINVAL; + if (!sta) { + err = -EINVAL; + goto out; + } cipher = mt7615_mac_get_cipher(key->cipher); - if (cipher == MT_CIPHER_NONE) - return -EOPNOTSUPP; + if (cipher == MT_CIPHER_NONE) { + err = -EOPNOTSUPP; + goto out; + } wcid = &wd->sta->wcid; @@ -178,19 +182,22 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, err = mt7615_mac_wtbl_update_key(dev, wcid, key->key, key->keylen, cipher, key->cmd); if (err < 0) - return err; + goto out; err = mt7615_mac_wtbl_update_pk(dev, wcid, cipher, key->keyidx, key->cmd); if (err < 0) - return err; + goto out; if (key->cmd == SET_KEY) wcid->cipher |= BIT(cipher); else wcid->cipher &= ~BIT(cipher); - return 0; +out: + kfree(key->key); + + return err; } void mt7663u_wtbl_work(struct work_struct *work)