From: Seung-Woo Kim Date: Tue, 18 Jan 2022 02:34:41 +0000 (+0900) Subject: xf86drm: check return value of asprintf() X-Git-Tag: accepted/tizen/base/riscv/20231204.084122~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d1380ac7984ad269db683e8212ed085a8bd0118;p=platform%2Fupstream%2Flibdrm.git xf86drm: check return value of asprintf() Check return value of asprintf() to fix build warning about not checked return. Change-Id: Iae8da56e7f743aa249869c58f6557148f799bd4c Signed-off-by: Seung-Woo Kim --- diff --git a/xf86drm.c b/xf86drm.c index 2e76f0ea..c033285f 100644 --- 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; }