rndis_wlan: Fix potential memory leak in update_pmkid()
Do not leak memory by updating pointer with potentially NULL realloc return value. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Acked-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Родитель
f41a9b3b15
Коммит
60f53cf990
|
@ -1803,6 +1803,7 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
|
||||||
struct cfg80211_pmksa *pmksa,
|
struct cfg80211_pmksa *pmksa,
|
||||||
int max_pmkids)
|
int max_pmkids)
|
||||||
{
|
{
|
||||||
|
struct ndis_80211_pmkid *new_pmkids;
|
||||||
int i, err, newlen;
|
int i, err, newlen;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
|
@ -1833,11 +1834,12 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
|
||||||
/* add new pmkid */
|
/* add new pmkid */
|
||||||
newlen = sizeof(*pmkids) + (count + 1) * sizeof(pmkids->bssid_info[0]);
|
newlen = sizeof(*pmkids) + (count + 1) * sizeof(pmkids->bssid_info[0]);
|
||||||
|
|
||||||
pmkids = krealloc(pmkids, newlen, GFP_KERNEL);
|
new_pmkids = krealloc(pmkids, newlen, GFP_KERNEL);
|
||||||
if (!pmkids) {
|
if (!new_pmkids) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
pmkids = new_pmkids;
|
||||||
|
|
||||||
pmkids->length = cpu_to_le32(newlen);
|
pmkids->length = cpu_to_le32(newlen);
|
||||||
pmkids->bssid_info_count = cpu_to_le32(count + 1);
|
pmkids->bssid_info_count = cpu_to_le32(count + 1);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче