linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
To: Qasim Ijaz <qasdev00@gmail.com>
Cc: marcan@marcan.st, fnkl.kernel@gmail.com,
	Sven Peter <sven@svenpeter.dev>, Janne Grunau <j@jannau.net>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu: apple-dart: fix potential null pointer deref
Date: Fri, 14 Mar 2025 19:51:44 -0400	[thread overview]
Message-ID: <Z9TBEAJkOrHIWype@blossom> (raw)
In-Reply-To: <20250314230102.11008-1-qasdev00@gmail.com>

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.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@gmail.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
> 


      reply	other threads:[~2025-03-14 23:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 23:01 [PATCH] iommu: apple-dart: fix potential null pointer deref Qasim Ijaz
2025-03-14 23:51 ` Alyssa Rosenzweig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9TBEAJkOrHIWype@blossom \
    --to=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=fnkl.kernel@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=j@jannau.net \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=qasdev00@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=sven@svenpeter.dev \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).