On Tue, Mar 15, 2016 at 12:05:00AM +0000, Gleb Smirnoff wrote:
> +int
> +sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS)
> +{
> +     uint64_t *out;
> +     int error;
> +
> +     out = malloc(arg2 * sizeof(uint64_t), M_TEMP, M_WAITOK);
> +     for (int i = 0; i < arg2; i++)
> +             out[i] = counter_u64_fetch(((counter_u64_t *)arg1)[i]);
> +
> +     error = SYSCTL_OUT(req, out, arg2 * sizeof(uint64_t));
> +
> +     if (error || !req->newptr)
> +             return (error);
> +
> +     /*
> +      * Any write attempt to a counter zeroes it.
> +      */
> +     for (int i = 0; i < arg2; i++)
> +             counter_u64_zero(((counter_u64_t *)arg1)[i]);
> + 
> +     return (0);
> +}
> 

This never frees tha allocated buffer.

It would be better to just put stuff to userspace in a loop and avoid
allocations entirely. but does not look like there are no friendly
macros for that.

-- 
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to