tech-kern archive

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

Re: [PATCH] netbsd32 swapctl, round 3



Le 01/02/2014 10:51, Martin Husemann a écrit :
> On Sat, Feb 01, 2014 at 08:41:15AM +0000, Emmanuel Dreyfus wrote:
>> Hi
>>
>> Here is my latest attempt at netbsd32 swapctl. I had to make uvm_swap_stats()
>> available to emul code, but that seems to be what it was intented for,
>> according to comments in the code.
> 
> Looks good.

Does not look good to me:

> +netbsd32_swapctl_stats(struct lwp *l, struct sys_swapctl_args *uap, 
> register_t *retval)
> +{
> +     struct swapent *sep;
> +     struct netbsd32_swapent *sep32;
> +     int count = SCARG(uap, misc);
> +     int i, error;
> +
> +     sep = kmem_alloc(sizeof(*sep) * count, KM_SLEEP);
> +     sep32 = kmem_alloc(sizeof(*sep32) * count, KM_SLEEP);
> +
> +     uvm_swap_stats(SWAP_STATS, sep, count, retval);
> +     count = *retval;
> +
> +     if (count < 1)
> +             goto out;

'error' is not initialized here

> +
> +     for (i = 0; i < count; i++) {
> +             sep32[i].se_dev = sep[i].se_dev;
> +             sep32[i].se_flags = sep[i].se_flags;
> +             sep32[i].se_nblks = sep[i].se_nblks;
> +             sep32[i].se_inuse = sep[i].se_inuse;
> +             sep32[i].se_priority = sep[i].se_priority;
> +             strlcpy(sep32[i].se_path, sep[i].se_path,
> +                     sizeof(sep32[i].se_path));
> +     }
> +
> +     error = copyout(sep32, SCARG(uap, arg), sizeof(*sep32) * count);
> +     
> +out:
> +     kmem_free(sep, sizeof(*sep));
> +     kmem_free(sep32, sizeof(*sep32));
> +
> +     return error;
> +}



Home | Main Index | Thread Index | Old Index