From nobody Mon Jun 8 23:57:32 2026 Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D3803D6477 for ; Mon, 25 May 2026 09:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779701037; cv=none; b=mhoFXZ7qIjN1eu8Iyy9EGAEHzG4NQas/OUwBtese6/r3kzWsbh+D0HDEKeur/BNDcmbwl8Kh5D2eLTwHVI+gyx6SOGwlXBbzYenyvevnVTv7CT6M103rjcubSHNdAXOhYUSiRKYOzi1BooPFgp03PCID7s07ELxT5mAt3rEsLVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779701037; c=relaxed/simple; bh=ot1Hj9GiN35Rn6MQidbBRW7vJ+45ilG/kY9mdc+hsrc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=YP4KX4iAk5P65c5UxRmpChxSE/uB5GOQf4SJI30kfMCSaKSCZxiD2UJElgro7VxLLOKiZ40uYlyF/fhcC33I0A6Ydc8lOlJgGKT0hLxOntPgK24WDhWEfDZvf1D6ZyZdyVma6qpOp6OxYRkE8VSZca1twybdlWUJK+VBxCzxMok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=GhrZTv8k; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="GhrZTv8k" Received: from DESKTOP-SUEFNF9.taila7e912.ts.net (unknown [221.228.238.82]) by smtp.qiye.163.com (Hmail) with ESMTP id 3fb3b3b0c; Mon, 25 May 2026 17:18:38 +0800 (GMT+08:00) From: Dawei Feng To: gregkh@linuxfoundation.org Cc: error27@gmail.com, omer.e.idrissi@gmail.com, hansg@kernel.org, hi@josie.lol, straube.linux@gmail.com, xela@viard.dev, ethantidmore06@gmail.com, liangjie@lixiang.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, Dawei Feng , Zilin Guan Subject: [PATCH] staging: rtl8723bs: fix mismatched free of HalData in rtw_sdio_if1_init() Date: Mon, 25 May 2026 17:18:36 +0800 Message-Id: <20260525091836.812565-1-dawei.feng@seu.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9e5e6ddb8703a2kunm898e496ea9790 X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVlDH0lDVktJGE0aTxhLTxlCT1YeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlJSUpVSUlDVUlIQ1VDSVlXWRYaDxIVHRRZQVlPS0hVSktJSE 5DQ1VKS0tVS1kG DKIM-Signature: a=rsa-sha256; b=GhrZTv8kHfk1G0bGObHlijMQijpeHuPwX9V+8apcs/APVUbZJlZiTGb+gC/ovAQXLb3rH2/XYEBnUavv0XcOBKzLitrIv8EOq7/pcd8++sxuFhyNu+WXLrlBAdOjNRKwhibSpNiqMck4sdJrVqe7GTMGtuNBfggYOHygLNp8FYk=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=G54wTtP8oOz8xFcg6YQ5EByDU85ATZ8w3S7XbFKtVVI=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" padapter->HalData is allocated via vzalloc(), but incorrectly freed using kfree() in the rtw_sdio_if1_init() error path. Using kfree() to release this vmalloc-backed buffer can lead to memory corruption. Use rtw_hal_data_deinit() to pair the free correctly and free HalData with vfree(). The bug was first flagged by an experimental static analysis tool we are developing for kernel memory-management bugs. Manual inspection confirms that the issue is still present in current mainline. An x86_64 allyesconfig build showed no new warnings. As we do not have suitable RTL8723BS SDIO hardware to test with, no runtime testing was able to be performed. Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Signed-off-by: Zilin Guan Signed-off-by: Dawei Feng Reviewed-by: Dan Carpenter --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging= /rtl8723bs/os_dep/sdio_intf.c index d0feb28b7043..67ef0e1271b0 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -287,8 +287,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_p= riv *dvobj, const struct status =3D _SUCCESS; =20 free_hal_data: - if (status !=3D _SUCCESS && padapter->HalData) - kfree(padapter->HalData); + if (status !=3D _SUCCESS) + rtw_hal_data_deinit(padapter); =20 if (status !=3D _SUCCESS) { rtw_wdev_unregister(padapter->rtw_wdev); --=20 2.34.1