xf86drm: check return value of asprintf()
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 18 Jan 2022 02:34:41 +0000 (11:34 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 4 Dec 2023 05:22:59 +0000 (14:22 +0900)
Check return value of asprintf() to fix build warning about not
checked return.

Change-Id: Iae8da56e7f743aa249869c58f6557148f799bd4c
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
xf86drm.c

index 2e76f0eab47761191b48aa1681057561f5b538b8..c033285fe1adfb6f3c3293a3458678a2e5a59778 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -360,9 +360,10 @@ drmGetFormatModifierNameFromNvidia(uint64_t modifier)
      * testing against TEGRA_TILE */
     if ((modifier & 0x10) == 0x10) {
         char *mod_nvidia;
-        asprintf(&mod_nvidia, "BLOCK_LINEAR_2D,HEIGHT=%"PRIu64",KIND=%"PRIu64","
+        if (asprintf(&mod_nvidia, "BLOCK_LINEAR_2D,HEIGHT=%"PRIu64",KIND=%"PRIu64","
                  "GEN=%"PRIu64",SECTOR=%"PRIu64",COMPRESSION=%"PRIu64"", height,
-                 kind, gen, sector, compression);
+                 kind, gen, sector, compression) < 0)
+               return NULL;
         return mod_nvidia;
     }
 
@@ -553,7 +554,9 @@ drmGetFormatModifierNameFromAmlogic(uint64_t modifier)
     else
         opts_str = "0";
 
-    asprintf(&mod_amlogic, "FBC,LAYOUT=%s,OPTIONS=%s", layout_str, opts_str);
+    if (asprintf(&mod_amlogic, "FBC,LAYOUT=%s,OPTIONS=%s", layout_str, opts_str)
+                   < 0)
+           return NULL;
     return mod_amlogic;
 }
 
@@ -617,7 +620,9 @@ drmGetFormatModifierNameFromVivante(uint64_t modifier)
        break;
     }
 
-    asprintf(&mod_vivante, "%s%s%s", color_tiling, tile_status, compression);
+    if (asprintf(&mod_vivante, "%s%s%s", color_tiling, tile_status, compression)
+                   < 0)
+           return NULL;
     return mod_vivante;
 }