Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: r8188eu: fix memleak in rtw_wx_set_enc_ext

Free the param struct if the caller sets an unsupported algorithm
and we return an error.

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20211019202356.12572-1-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Martin Kaiser and committed by
Greg Kroah-Hartman
26f44837 c052cc1a

+3 -2
+3 -2
drivers/staging/r8188eu/os_dep/ioctl_linux.c
··· 1897 1897 struct ieee_param *param = NULL; 1898 1898 struct iw_point *pencoding = &wrqu->encoding; 1899 1899 struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; 1900 - int ret = 0; 1900 + int ret = -1; 1901 1901 1902 1902 param_len = sizeof(struct ieee_param) + pext->key_len; 1903 1903 param = kzalloc(param_len, GFP_KERNEL); ··· 1923 1923 alg_name = "CCMP"; 1924 1924 break; 1925 1925 default: 1926 - return -1; 1926 + goto out; 1927 1927 } 1928 1928 1929 1929 strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); ··· 1950 1950 1951 1951 ret = wpa_set_encryption(dev, param, param_len); 1952 1952 1953 + out: 1953 1954 kfree(param); 1954 1955 return ret; 1955 1956 }