[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z9TBEAJkOrHIWype@blossom>
Date: Fri, 14 Mar 2025 19:51:44 -0400
From: Alyssa Rosenzweig <alyssa@...enzweig.io>
To: Qasim Ijaz <qasdev00@...il.com>
Cc: marcan@...can.st, fnkl.kernel@...il.com,
Sven Peter <sven@...npeter.dev>, Janne Grunau <j@...nau.net>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>, asahi@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iommu: apple-dart: fix potential null pointer deref
Reviewed-by: Alyssa Rosenzweig <alyssa@...enzweig.io>
Le Fri , Mar 14, 2025 at 11:01:02PM +0000, Qasim Ijaz a écrit :
> If kzalloc() fails, accessing cfg->supports_bypass causes a null pointer dereference.
>
> Fix by checking for NULL immediately after allocation and returning -ENOMEM.
>
> Fixes: 3bc0102835f6 ("iommu: apple-dart: Allow mismatched bypass support")
> Signed-off-by: Qasim Ijaz <qasdev00@...il.com>
> ---
> drivers/iommu/apple-dart.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
> index 13ccb801f52a..e13501541fdd 100644
> --- a/drivers/iommu/apple-dart.c
> +++ b/drivers/iommu/apple-dart.c
> @@ -797,12 +797,11 @@ static int apple_dart_of_xlate(struct device *dev,
>
> if (!cfg) {
> cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
> -
> + if (!cfg)
> + return -ENOMEM;
> /* Will be ANDed with DART capabilities */
> cfg->supports_bypass = true;
> }
> - if (!cfg)
> - return -ENOMEM;
> dev_iommu_priv_set(dev, cfg);
>
> cfg_dart = cfg->stream_maps[0].dart;
> --
> 2.39.5
>
Powered by blists - more mailing lists