LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yossi Etigin" <yosefe@voltaire.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: Alex Netes <alexne@voltaire.com>
Subject: RE: possible bug in ppc_vm_region_alloc()
Date: Tue, 3 Aug 2010 09:21:12 +0300	[thread overview]
Message-ID: <7E95F01E94AB484F83061FCFA35B39F889F230@exil.voltaire.com> (raw)
In-Reply-To: <7E95F01E94AB484F83061FCFA35B39F801322D@exil.voltaire.com>


Hello,

(I repost this because looks like the previous was filtered because I
was not subscribed to the list)

We are looking at dma_alloc_coherent(), which uses ppc_vm_region_alloc()
on the coherent region "consistent_head".
It seems to us there is a bug in the function ppc_vm_region_alloc().
The check "if (addr > end)" should be "if (addr >=3D end)"

If for example it is called once when the size is the entire coherent
region, the second time it will allocate a region outside the valid
memory.
It will happen because the list will contain one element (besides the
head) which is equal to the head, and neither condition will cause a
"goto nospc". Then the list iteration will end and the new region will
be allocated right after the valid region.

	list_for_each_entry(c, &head->vm_list, vm_list) {
		if ((addr + size) < addr)
			goto nospc;
		if ((addr + size) <=3D c->vm_start)
			goto found;
		addr =3D c->vm_end;
		if (addr > end)                    <=3D=3D=3D here
			goto nospc;
	}

--Yossi

           reply	other threads:[~2010-08-03  6:21 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <7E95F01E94AB484F83061FCFA35B39F801322D@exil.voltaire.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7E95F01E94AB484F83061FCFA35B39F889F230@exil.voltaire.com \
    --to=yosefe@voltaire.com \
    --cc=alexne@voltaire.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox