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 <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
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)