From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795895972; b=4Ual120NFPTI3h6fEcdmMMohzNdhMsW/pX0Akgaj8NJ5gXpF9eEouOk1r3OW/Ifo+ONx pwGDBHcGFCx6y/Yw/0r04LZXaDM+M5U1RhNIEd4UEHur1XOJdXVgjZrW1TQMEZQmuvSEV SozJ/3DMx+tQFu2xDsjVacz8rNhhkzMwPHqoy8nTICMmpk2dUkILgpcBNremltH2TtQub 0MojI0gAPbydWuFKg+TEVusZrOuI0XRGEj3vE8lkDslrCYW6z9ELafQWyNc5Y/iH+gk7h 63Mp5c2lUzjfKbMqlkkXE2qa1SnYl6YC816L+xqQCXRrzJ0R1X8XNc/8YmgP2OtvXWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795895972; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=kv6Ss92bnSei/q6ntoyra3FmBqElNyLdWyF6l5edrZ4=; b=dK8s+3LfCormtIp2IscCug0eW4S/mhaitCaqtq9Ca7cNave2wqji6EBfQablO3ybyP6Y izXrAWhc601M67s1JtAecByWOIITH71WnSgpao92s9rx9eNJK+x/W8RA8RSgEU8s+kasD nYZx3ByQQ3JFlzNyxZ/II2MobwjD4rjLJmnzRzvAIrn1owv/fNMb8WGpqIHDYEJv7ET8T e6xxFsj3CLxN+8teiut/K288AEhdp5khbfnKB9o4TifuGkTN56ytqnE8P0qRD9ZiwMWRx VZke+z+EcoIhxoEYXK66UkTF2AqcPtikNV/JhJP92nxRovlZkWUT6bvJeIbcAiwq1WA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lAxWemZG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0869D606A31C; Sat, 28 Nov 2026 19:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lAxWemZG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19E421F00893; Sat, 28 Nov 2026 19:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795895971; bh=kv6Ss92bnSei/q6ntoyra3FmBqElNyLdWyF6l5edrZ4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=lAxWemZGvhsgX/z2YylVDUx3xvwpNE+LfPyrqKiEdtMZOOfAO2VIkySnjfmV4dL6p +2jq+9g06vB09Qyw8CD32bAcguDaeIBknMQOXGY3Qf68ANU8wjgW1M1hD/SvQ3HFQb Gpa3Oe4TETwtDtjpAATR901vn1Zft+zu/51VEAmn4vhZFmfzIRU6OZglsbNz+OvDYE GqFYQNnaN3IOSEMTlQCcdHxlptIlJ9yZQ2u2lRxGC7t9mq9ZmkEHsexQ177Ygq/BKF VGfpUqAYSKfvDODTfyInre20uMIeOM7zrpbsiSaCWRAet55Dp1O2F5IFoF9CVEQrDJ 5SlZDkRObK14w== Date: Sat, 28 Nov 2026 19:59:25 +0000 From: Jonathan Cameron To: Guangshuo Li Cc: David Lechner , Nuno =?UTF-8?B?U8Oh?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Andy Shevchenko Subject: Re: [PATCH v2] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind Message-ID: <20261128195925.688dc921@jic23-hlaptop> In-Reply-To: <20261124135828.2274815-1-liguangshuo@mail.sdu.edu.cn> References: <20261124135828.2274815-1-liguangshuo@mail.sdu.edu.cn> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 24 Nov 2026 21:58:28 +0800 Guangshuo Li wrote: > A channel reference does not keep the DMA provider bound. If the EDMA > provider is unbound first, ADC removal accesses the freed channel when > freeing its DMA buffer and releasing the channel. >=20 > Link the ADC platform device to the provider so the ADC is removed first, > including when firmware device links are disabled. The driver core drops > the link on probe failure or ADC removal. >=20 > This issue was found by our static analysis tool under development. >=20 > Fixes: f438b9da75eb ("drivers: iio: ti_am335x_adc: add dma support") > Cc: stable@vger.kernel.org > Signed-off-by: Guangshuo Li =46rom the sashiko review of patch 1 there may be other gremlins hiding=20 in this driver. This seems ok though. Applied to the testing branch of iio.git. So lined up for next merge window rather than rushing it in. Jonathan > --- > Changes in v2: > - Use dmaengine_get_provider_device() to obtain the supplier device. >=20 > Backports need 61527d7e6998 ("dmaengine: add dmaengine_get_provider_dev= ice() API"). >=20 > drivers/iio/adc/ti_am335x_adc.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_= adc.c > index 0c3e0e9e8364..c7f8bafe0f4a 100644 > --- a/drivers/iio/adc/ti_am335x_adc.c > +++ b/drivers/iio/adc/ti_am335x_adc.c > @@ -546,6 +546,11 @@ static int tiadc_request_dma(struct platform_device = *pdev, > return ret; > } > =20 > + if (!device_link_add(&pdev->dev, > + dmaengine_get_provider_device(dma->chan), > + DL_FLAG_AUTOREMOVE_CONSUMER)) > + goto err; > + > /* RX buffer */ > dma->buf =3D dma_alloc_coherent(dmaengine_get_dma_device(dma->chan), DM= A_BUFFER_SIZE, > &dma->addr, GFP_KERNEL); >=20 > base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f