From nobody Mon Feb 9 01:11:48 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 0E61620E334; Mon, 20 Oct 2025 07:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760946587; cv=none; b=Tu5U/x9RmSTKl9Mx0YcJqQXhb0dane76L/JHjSLrL78QUhhB5TRMnlEVos2pom+GBWITK5Ex3FAK2j2oJ+rbpU1Ogh4K1gqw0XYkTQWUyi87AywWUzNIh4mAntLQlkdEMxUYSeazdn8Yo8WSH5AEtsHOAanfyUO1h1zdJgc4q3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760946587; c=relaxed/simple; bh=rqF2+4aZsZgXwI99r/vp0x9hXEbZsi9gPenHK717Rp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p9oaAsbmdY0XZi+LjIiD5BkQ7V24I50eiYJ8A0HUtTqRp09Xd4Kb8ZheWeN2vFZ20pT3258AbVyLwEaGy0zaz6PNx2CnLcH9QILHbvf1DGA1K6xLGfQ+YTGV2dlRsCPtutTtXHE9G//WNfgFV61k5HFRZy+3NeeQBbqEA9MiuqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 4f4e1ddaad8911f0a38c85956e01ac42-20251020 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:077d9843-85d1-45bd-9f42-d164766ef793,IP:0,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:25 X-CID-META: VersionHash:a9d874c,CLOUDID:cb42775910660d13e7362869089db852,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850,TC:nil,Content:0|50,EDM:5, IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV: 0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 4f4e1ddaad8911f0a38c85956e01ac42-20251020 X-User: xiaopei01@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 571335398; Mon, 20 Oct 2025 15:49:30 +0800 From: Pei Xiao To: eugen.hristev@linaro.org Cc: alexandre.belloni@bootlin.com, jic23@kernel.org, lars@metafoo.de, linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, nicolas.ferre@microchip.com, xiaopei01@kylinos.cn Subject: [PATCH v2] iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driver Date: Mon, 20 Oct 2025 15:49:25 +0800 Message-Id: <268cbf0a5d9b931fcf6c025c53cc698ce78e4689.1760946527.git.xiaopei01@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: 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 Content-Type: text/plain; charset="utf-8" at91_adc_interrupt can call at91_adc_touch_data_handler function to start the work by schedule_work(&st->touch_st.workq). If we remove the module which will call at91_adc_remove to make cleanup, it will free indio_dev through iio_device_unregister while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows: CPU0 CPU1 | at91_adc_workq_handler at91_adc_remove | iio_device_unregister(indio_dev) | //free indio_dev | | iio_push_to_buffers(indio_dev) | //use indio_dev Fix it by ensuring that the work is canceled before proceeding with the cleanup in at91_adc_remove. Fixes: 3ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position a= nd pressure channels") Signed-off-by: Pei Xiao --- drivers/iio/adc/at91-sama5d2_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama= 5d2_adc.c index b4c36e6a7490..1cd6ce61cf17 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -2480,6 +2480,7 @@ static void at91_adc_remove(struct platform_device *p= dev) struct iio_dev *indio_dev =3D platform_get_drvdata(pdev); struct at91_adc_state *st =3D iio_priv(indio_dev); =20 + cancel_work_sync(&st->touch_st.workq); iio_device_unregister(indio_dev); =20 at91_adc_dma_disable(st); --=20 2.25.1