Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1515330 > unrolled thread
| Started by | Eric Engestrom <eric.engestrom@imgtec.com> |
|---|---|
| First post | 2016-11-04 18:40 +0100 |
| Last post | 2016-11-04 18:40 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH variant 1] drm: make drm_get_format_name atomic/irq safe again Eric Engestrom <eric.engestrom@imgtec.com> - 2016-11-04 18:40 +0100
| From | Eric Engestrom <eric.engestrom@imgtec.com> |
|---|---|
| Date | 2016-11-04 18:40 +0100 |
| Subject | [PATCH variant 1] drm: make drm_get_format_name atomic/irq safe again |
| Message-ID | <szQD7-4MR-11@gated-at.bofh.it> |
Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07
drm: make drm_get_format_name thread-safe
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
[danvet: Clarify that the returned pointer must be freed with
kfree().]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
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@gmail.com> (GFP_ATOMIC)
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com> (kasprintf)
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
---
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
Back to top | Article view | linux.kernel
csiph-web