[Intel-gfx] [PATCH 4/4] drm: Add decoding of DRM and KMS ioctls

Patrik Jakobsson patrik.jakobsson at linux.intel.com
Wed Jun 10 07:27:03 PDT 2015


On Wed, Jun 10, 2015 at 01:46:53AM +0300, Dmitry V. Levin wrote:
> On Tue, Jun 09, 2015 at 01:26:44PM +0200, Patrik Jakobsson wrote:
> [...]
> > +static int drm_version(struct tcb *tcp, const unsigned int code, long arg)
> > +{
> > +	struct drm_version ver;
> > +	char *name, *date, *desc;
> > +	int ret;
> > +
> > +	if (entering(tcp) || umove(tcp, arg, &ver))
> > +		return 0;
> > +
> > +	name = calloc(ver.name_len + 1, 1);
> > +	if (!name)
> > +		return 0;
> > +	ret = umovestr(tcp, (long)ver.name, ver.name_len, name);
> > +	if (ret < 0)
> > +		goto free_name;
> 
> No need to allocate (arbitrary sized chunk of) memory just to fetch
> a string that has to be printed.  There is a function called printstr()
> to print such strings in a properly quoted form.
> 

Yes, that's much nicer. Fixed in v2.

> 
> -- 
> ldv




More information about the Intel-gfx mailing list