[PATCH 1/5] vm/device_pager.c: dev_pager_alloc: 'size' must be non-zero

Meyer, Conrad conrad.meyer at isilon.com
Wed Mar 12 15:36:47 UTC 2014


On Wed, Mar 12, 2014 at 3:30 AM, Konstantin Belousov <kostikbel at gmail.com> wrote:
>
> Thank you for the submission, I committed four patches, except this one.
>

Thanks!

>
> On Tue, Mar 11, 2014 at 05:19:39PM -0700, Conrad Meyer wrote:
> > If size is zero, paddr is used uninitialized when assigning
> > object1->pg_color.
> So the issue there is only with non-managed device pager, right ?
> Please note that GEM explicitely initializes color in the constructor.
>
> I do not like the change below, it puts the policy into pager, while
> currently the decision is up to managed pager consumers, e.g. GEM,
> which do the similar check on its own.
>
> I prefer a different way to shut down the warning, please see the
> patch at the end of the message.  Does it work for you ?
>
> diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c
> index 13491ba..4cd245a 100644
> --- a/sys/vm/device_pager.c
> +++ b/sys/vm/device_pager.c
> @@ -414,6 +414,7 @@ old_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
>          * XXX assumes VM_PROT_* == PROT_*
>          */
>         npages = OFF_TO_IDX(size);
> +       paddr = 0; /* Make paddr initialized for the case of size == 0. */
>         for (off = foff; npages--; off += PAGE_SIZE) {
>                 if (csw->d_mmap(dev, off, &paddr, (int)prot, &dummy) != 0) {
>                         dev_relthread(dev, ref);

Looks good to me.

Thanks,
Conrad


More information about the freebsd-hackers mailing list