From 79d033456436ec354ff37b68298dbf84beaedf6e Mon Sep 17 00:00:00 2001 From: jsg Date: Tue, 15 Aug 2023 03:51:29 +0000 Subject: [PATCH] make sure the end result is NULL if malloc failed --- sys/dev/pci/drm/dma-resv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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); -- 2.20.1