Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07 drm: make drm_get_format_name thread-safe Signed-off-by: Eric Engestrom <eric@xxxxxxxxxxxx> [danvet: Clarify that the returned pointer must be freed with kfree().] Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx> Note (Rob Clark): I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that. Suggested-by: Rob Clark <robdclark@xxxxxxxxx> (GFP_ATOMIC) Suggested-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> (kasprintf) Signed-off-by: Eric Engestrom <eric.engestrom@xxxxxxxxxx> --- I'll send another variant tonight that moves the allocation to the callers (sounds cleaner to me, although there'll be some code duplication and more opportunities to make mistakes I guess). --- drivers/gpu/drm/drm_fourcc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index 29c56b4..66dcf21 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -87,9 +87,7 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format); */ char *drm_get_format_name(uint32_t format) { - char *buf = kmalloc(32, GFP_KERNEL); - - snprintf(buf, 32, + return kasprintf(GFP_ATOMIC, "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff), @@ -97,8 +95,6 @@ char *drm_get_format_name(uint32_t format) printable_char((format >> 24) & 0x7f), format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little", format); - - return buf; } EXPORT_SYMBOL(drm_get_format_name); -- Cheers, Eric _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel