From: jsg Date: Sat, 3 Feb 2024 09:15:57 +0000 (+0000) Subject: return early if malloc fails to avoid use after free X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=916d47d651323dc244f948cb3d82b01b465025a0;p=openbsd return early if malloc fails to avoid use after free found by "passing freed memory 'edid'" smatch warning --- diff --git a/sys/dev/pci/drm/drm_edid.c b/sys/dev/pci/drm/drm_edid.c index 3766ff2cfcd..ba92bd045bd 100644 --- a/sys/dev/pci/drm/drm_edid.c +++ b/sys/dev/pci/drm/drm_edid.c @@ -2120,8 +2120,10 @@ static struct edid *edid_filter_invalid_blocks(struct edid *edid, kfree(edid); #else new = kmalloc(*alloc_size, GFP_KERNEL); - if (!new) + if (!new) { kfree(edid); + return NULL; + } memcpy(new, edid, EDID_LENGTH); kfree(edid); #endif