From: jsg Date: Tue, 15 Aug 2023 03:51:29 +0000 (+0000) Subject: make sure the end result is NULL if malloc failed X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=79d033456436ec354ff37b68298dbf84beaedf6e;p=openbsd make sure the end result is NULL if malloc failed --- diff --git a/sys/dev/pci/drm/dma-resv.c b/sys/dev/pci/drm/dma-resv.c index 8461b4dde47..d3f7c01f3e0 100644 --- a/sys/dev/pci/drm/dma-resv.c +++ b/sys/dev/pci/drm/dma-resv.c @@ -588,13 +588,12 @@ int dma_resv_get_fences(struct dma_resv *obj, enum dma_resv_usage usage, #else nfences = kmalloc(count * sizeof(void *), GFP_KERNEL); - if (nfences != NULL && *fences != NULL) + if (nfences != NULL && *fences != NULL) { memcpy(nfences, *fences, (count - 1) * sizeof(void *)); - if (nfences) { kfree(*fences); - new_fences = nfences; } + new_fences = nfences; #endif if (count && !new_fences) { kfree(*fences);