drm: move allocation out of drm_get_format_name()
The function's behaviour was changed in90844f0004
, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory. Rob Clark also noticed it was also allocating GFP_KERNEL memory in atomic contexts, breaking them. Instead of having to allocate GFP_ATOMIC memory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function. The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory. Fixes:90844f0004
("drm: make drm_get_format_name thread-safe") Cc: Rob Clark <robdclark@gmail.com> Cc: Christian König <christian.koenig@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Acked-by: Rob Clark <robdclark@gmail.com> Acked-by: Sinclair Yeh <syeh@vmware.com> (vmwgfx) Reviewed-by: Jani Nikula <jani.nikula@intel.com> Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Eric Engestrom <eric@engestrom.ch> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20161112011309.9799-1-eric@engestrom.ch
This commit is contained in:

committed by
Daniel Vetter

parent
f92e1ee52a
commit
b3c11ac267
@@ -45,6 +45,14 @@ struct drm_format_info {
|
||||
u8 vsub;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct drm_format_name_buf - name of a DRM format
|
||||
* @str: string buffer containing the format name
|
||||
*/
|
||||
struct drm_format_name_buf {
|
||||
char str[32];
|
||||
};
|
||||
|
||||
const struct drm_format_info *__drm_format_info(u32 format);
|
||||
const struct drm_format_info *drm_format_info(u32 format);
|
||||
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
|
||||
@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);
|
||||
int drm_format_vert_chroma_subsampling(uint32_t format);
|
||||
int drm_format_plane_width(int width, uint32_t format, int plane);
|
||||
int drm_format_plane_height(int height, uint32_t format, int plane);
|
||||
char *drm_get_format_name(uint32_t format) __malloc;
|
||||
const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
|
||||
|
||||
#endif /* __DRM_FOURCC_H__ */
|
||||
|
Reference in New Issue
Block a user