make sure the end result is NULL if malloc failed
authorjsg <jsg@openbsd.org>
Tue, 15 Aug 2023 03:51:29 +0000 (03:51 +0000)
committerjsg <jsg@openbsd.org>
Tue, 15 Aug 2023 03:51:29 +0000 (03:51 +0000)
sys/dev/pci/drm/dma-resv.c

index 8461b4d..d3f7c01 100644 (file)
@@ -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);