Skip to content

Commit b874149

Browse files
qasim-ijazjoergroedel
authored andcommitted
iommu: apple-dart: fix potential null pointer deref
If kzalloc() fails, accessing cfg->supports_bypass causes a null pointer dereference. Fix by checking for NULL immediately after allocation and returning -ENOMEM. Fixes: 3bc0102 ("iommu: apple-dart: Allow mismatched bypass support") Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Link: https://lore.kernel.org/r/20250314230102.11008-1-qasdev00@gmail.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 3bc0102 commit b874149

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/iommu/apple-dart.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,11 @@ static int apple_dart_of_xlate(struct device *dev,
797797

798798
if (!cfg) {
799799
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
800-
800+
if (!cfg)
801+
return -ENOMEM;
801802
/* Will be ANDed with DART capabilities */
802803
cfg->supports_bypass = true;
803804
}
804-
if (!cfg)
805-
return -ENOMEM;
806805
dev_iommu_priv_set(dev, cfg);
807806

808807
cfg_dart = cfg->stream_maps[0].dart;

0 commit comments

Comments
 (0)