From: Eric Engestrom <eric.engestrom@imgtec.com>
To: Rob Clark <robdclark@gmail.com>
Cc: Eric Engestrom <eric@engestrom.ch>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: make drm_get_format_name atomic/irq safe again
Date: Fri, 4 Nov 2016 17:32:24 +0000 [thread overview]
Message-ID: <20161104173224.GJ25290@imgtec.com> (raw)
In-Reply-To: <CAF6AEGuU81RxWXYJmc2ecNHKm=T6MLF_bx6rUefEeZSnWh48=g@mail.gmail.com>
On Friday, 2016-11-04 13:12:51 -0400, Rob Clark wrote:
> On Fri, Nov 4, 2016 at 12:27 PM, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> > On Fri, Nov 04, 2016 at 11:32:45AM -0400, Rob Clark wrote:
> >> 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: 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.
> >>
> >> Signed-off-by: Rob Clark <robdclark@gmail.com>
> >> ---
> >> drivers/gpu/drm/drm_fourcc.c | 5 ++++-
> >> 1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> >> index cbb8b77..2be9ea8 100644
> >> --- a/drivers/gpu/drm/drm_fourcc.c
> >> +++ b/drivers/gpu/drm/drm_fourcc.c
> >> @@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);
> >> */
> >> char *drm_get_format_name(uint32_t format)
> >> {
> >> - char *buf = kmalloc(32, GFP_KERNEL);
> >> + char *buf = kmalloc(32, GFP_ATOMIC);
> >> +
> >> + if (!buf)
> >> + return NULL;
Unrelated bug, thanks for that fix too :)
> >>
> >> snprintf(buf, 32,
> >> "%c%c%c%c %s-endian (0x%08x)",
> >
> > Why aren't we using kasprintf()?
Because I didn't know it was a thing :(
Patch using it incoming.
> >
> > Or we could have just made the caller provide the buffer...
>
> I guess kasprintf() would do the job (although still not address the
> fact that we still always do the sprintf bits, rather than only doing
> it when debug logs are enabled).. caller provided buffer would be
> better. And make it more obvious that something needs to be fixed
> when merging/rebasing patches that started life before this change
> landed.
>
> I still kinda like the idea of making vsprintf know about fourcc's
> with a new format string, and just making drm_get_format_name() go
> away.
>
> But I don't really have time atm to re-work all the callers of
> drm_get_format_name(). So I guess unless someone else does, I'd go w/
> kasprintf() for now.
That sounds cleaner to me indeed, I'll send a patch doing that tonight.
Any idea for the name? drm_get_format_name_safe(uint32_t, char*)?
I could also keep the same name and rely on the function signature
change to make sure any merging of the old function call will break the
compilation and be noticed that way.
Looks like I'm obviously not qualified to choose which is the best
option, so I'll leave that to you guys :)
Cheers,
Eric
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-11-04 17:32 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 15:32 [PATCH] drm: make drm_get_format_name atomic/irq safe again Rob Clark
2016-11-04 15:45 ` Rob Clark
2016-11-04 16:27 ` Ville Syrjälä
2016-11-04 17:12 ` Rob Clark
2016-11-04 17:32 ` Eric Engestrom [this message]
2016-11-04 17:33 ` [PATCH variant 1] " Eric Engestrom
2016-11-04 17:33 ` Eric Engestrom
2016-11-04 17:50 ` [PATCH] " Rob Clark
2016-11-04 18:13 ` Ville Syrjälä
2016-11-05 1:23 ` Eric Engestrom
2016-11-05 1:33 ` [PATCH] drm: move allocation out of drm_get_format_name() Eric Engestrom
2016-11-05 1:33 ` Eric Engestrom
2016-11-05 6:56 ` Thomas Hellstrom
2016-11-05 6:56 ` Thomas Hellstrom
2016-11-05 12:11 ` Christian König
2016-11-05 12:11 ` Christian König
2016-11-05 16:38 ` Eric Engestrom
2016-11-05 16:38 ` Eric Engestrom
2016-11-05 16:49 ` Rob Clark
2016-11-05 16:49 ` Rob Clark
2016-11-06 9:47 ` Christian König
2016-11-06 9:47 ` Christian König
2016-11-06 13:03 ` Rob Clark
2016-11-06 13:03 ` Rob Clark
2016-11-07 0:47 ` Eric Engestrom
2016-11-07 0:47 ` Eric Engestrom
2016-11-07 0:48 ` [PATCH v2] " Eric Engestrom
2016-11-07 0:48 ` Eric Engestrom
2016-11-07 7:46 ` Christian König
2016-11-07 7:46 ` Christian König
2016-11-07 8:10 ` Jani Nikula
2016-11-07 8:10 ` Jani Nikula
2016-11-07 17:12 ` Eric Engestrom
2016-11-07 17:12 ` Eric Engestrom
2016-11-07 17:38 ` Jani Nikula
2016-11-07 17:38 ` Jani Nikula
2016-11-08 10:15 ` [Intel-gfx] " Daniel Vetter
2016-11-08 10:15 ` Daniel Vetter
2016-11-09 0:17 ` [PATCH v3] " Eric Engestrom
2016-11-09 0:17 ` Eric Engestrom
2016-11-09 1:09 ` [Intel-gfx] " Daniel Vetter
2016-11-09 1:09 ` Daniel Vetter
2016-11-09 1:13 ` Daniel Vetter
2016-11-09 1:13 ` [Intel-gfx] " Daniel Vetter
2016-11-09 11:42 ` Eric Engestrom
2016-11-09 11:42 ` [Intel-gfx] " Eric Engestrom
2016-11-09 13:13 ` Daniel Vetter
2016-11-09 13:13 ` Daniel Vetter
2016-11-09 16:59 ` Eric Engestrom
2016-11-09 16:59 ` [Intel-gfx] " Eric Engestrom
2016-11-10 10:03 ` Laurent Pinchart
2016-11-10 10:03 ` [Intel-gfx] " Laurent Pinchart
2016-11-10 10:30 ` Jani Nikula
2016-11-10 10:30 ` Jani Nikula
2016-11-10 10:59 ` Laurent Pinchart
2016-11-10 10:59 ` Laurent Pinchart
2016-11-10 11:03 ` Jani Nikula
2016-11-10 11:03 ` Jani Nikula
2016-11-11 9:26 ` Daniel Vetter
2016-11-11 9:26 ` Daniel Vetter
2016-11-12 1:12 ` [PATCH v4] " Eric Engestrom
2016-11-12 1:12 ` Eric Engestrom
2016-11-07 14:45 ` [PATCH v2] " Rob Clark
2016-11-07 14:45 ` Rob Clark
2016-11-07 18:12 ` Sinclair Yeh
2016-11-07 18:12 ` Sinclair Yeh
2016-11-05 1:52 ` [PATCH] drm: make drm_get_format_name atomic/irq safe again Rob Clark
2016-11-05 2:15 ` ✓ Fi.CI.BAT: success for drm: move allocation out of drm_get_format_name() Patchwork
2016-11-07 1:15 ` ✗ Fi.CI.BAT: warning for drm: move allocation out of drm_get_format_name() (rev2) Patchwork
2016-11-07 8:18 ` Saarinen, Jani
2016-11-09 0:31 ` ✗ Fi.CI.BAT: failure for drm: move allocation out of drm_get_format_name() (rev3) Patchwork
2016-11-12 1:45 ` ✓ Fi.CI.BAT: success for drm: move allocation out of drm_get_format_name() (rev4) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161104173224.GJ25290@imgtec.com \
--to=eric.engestrom@imgtec.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@engestrom.ch \
--cc=robdclark@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.