From: Dan Carpenter <dan.carpenter@oracle.com>
To: maarten.lankhorst@canonical.com
Cc: dri-devel@lists.freedesktop.org
Subject: re: drm/nouveau: do not allow negative sizes for now
Date: Wed, 24 Jul 2013 18:55:16 +0300 [thread overview]
Message-ID: <20130724155516.GA14591@elgon.mountain> (raw)
Hello Maarten Lankhorst,
This is a semi-automatic email about new static checker warnings.
The patch 0108bc808107: "drm/nouveau: do not allow negative sizes for
now" from Jul 7, 2013, leads to the following Smatch complaint:
drivers/gpu/drm/nouveau/nouveau_bo.c:222 nouveau_bo_new()
warn: variable dereferenced before check 'drm->client.base.vm' (see line 201)
drivers/gpu/drm/nouveau/nouveau_bo.c
200 int type = ttm_bo_type_device;
201 int max_size = INT_MAX & ~((1 << drm->client.base.vm->vmm->lpg_shift) - 1);
^^^^^^^^^^^^^^^^^^^
New dereference.
202
203 if (size <= 0 || size > max_size) {
204 nv_warn(drm, "skipped size %x\n", (u32)size);
205 return -EINVAL;
206 }
207
208 if (sg)
209 type = ttm_bo_type_sg;
210
211 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
212 if (!nvbo)
213 return -ENOMEM;
214 INIT_LIST_HEAD(&nvbo->head);
215 INIT_LIST_HEAD(&nvbo->entry);
216 INIT_LIST_HEAD(&nvbo->vma_list);
217 nvbo->tile_mode = tile_mode;
218 nvbo->tile_flags = tile_flags;
219 nvbo->bo.bdev = &drm->ttm.bdev;
220
221 nvbo->page_shift = 12;
222 if (drm->client.base.vm) {
^^^^^^^^^^^^^^^^^^^
Old check.
223 if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
224 nvbo->page_shift = drm->client.base.vm->vmm->lpg_shift;
regards,
dan carpenter
next reply other threads:[~2013-07-24 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-24 15:55 Dan Carpenter [this message]
2013-07-27 8:17 ` [PATCH] drm/nouveau: fix size check for cards without vm Maarten Lankhorst
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=20130724155516.GA14591@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@canonical.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;
as well as URLs for NNTP newsgroup(s).