dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: jglisse@redhat.com
Cc: dri-devel@lists.freedesktop.org
Subject: re: drm/ttm: Print debug information on memory manager when eviction fails
Date: Wed, 4 Dec 2013 17:05:59 +0300	[thread overview]
Message-ID: <20131204140559.GA11539@elgon.mountain> (raw)

Hello Jerome Glisse,

The patch fb53f8621a3f: "drm/ttm: Print debug information on memory
manager when eviction fails" from Dec 9, 2009, leads to the following
static checker warning: "drivers/gpu/drm/ttm/ttm_bo.c:1494
ttm_mem_reg_is_pci()
	 warn: buffer overflow 'bdev->man' 8 <= 8"

drivers/gpu/drm/ttm/ttm_bo.c
    56  static inline int ttm_mem_type_from_flags(uint32_t flags, uint32_t *mem_type)
    57  {
    58          int i;
    59  
    60          for (i = 0; i <= TTM_PL_PRIV5; i++)
    61                  if (flags & (1 << i)) {
    62                          *mem_type = i;
    63                          return 0;
    64                  }
    65          return -EINVAL;
    66  }

--- [snip] to the ttm_bo_mem_space() function:

   869          for (i = 0; i < placement->num_placement; ++i) {
   870                  ret = ttm_mem_type_from_flags(placement->placement[i],
   871                                                  &mem_type);
   872                  if (ret)
   873                          return ret;
   874                  man = &bdev->man[mem_type];
   875  

So after ttm_mem_type_from_flags then mem_type can be TTM_PL_PRIV5 (8)
but the bdev->man[] array only has TTM_NUM_MEM_TYPES (8) elements so we
are one space beyond the end of the array.

regards,
dan carpenter

                 reply	other threads:[~2013-12-04 14:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20131204140559.GA11539@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jglisse@redhat.com \
    /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