Re: [PATCH 4/4] drm: Add decoding of DRM and KMS ioctls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
ldv

Attachment: pgp9dp9dU7QIl.pgp
Description: PGP signature

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux