From: Alan Cox <alan@linux.jf.intel.com>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] gma500: Fix dumb create crash
Date: Mon, 09 May 2011 16:04:45 +0100 [thread overview]
Message-ID: <20110509150437.28865.72860.stgit@localhost.localdomain> (raw)
In-Reply-To: <20110509150334.28865.25665.stgit@localhost.localdomain>
The error path from gtt_alloc returns NULL not a ptr error. The underlying
fail is caused by a bug in the size calculation. With these two fixed it
passes kmstest, although it's not really doing anything useful yet.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/staging/gma500/psb_gem.c | 6 +++---
drivers/staging/gma500/psb_gtt.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/gma500/psb_gem.c b/drivers/staging/gma500/psb_gem.c
index d47c187..518f8c1 100644
--- a/drivers/staging/gma500/psb_gem.c
+++ b/drivers/staging/gma500/psb_gem.c
@@ -100,8 +100,8 @@ static int psb_gem_create(struct drm_file *file,
/* Allocate our object - for now a direct gtt range which is not
stolen memory backed */
r = psb_gtt_alloc_range(dev, size, "gem", 0);
- if (IS_ERR(r))
- return PTR_ERR(r);
+ if (r == NULL)
+ return -ENOSPC;
/* Initialize the extra goodies GEM needs to do all the hard work */
if (drm_gem_object_init(dev, &r->gem, size) != 0) {
psb_gtt_free_range(dev, r);
@@ -135,7 +135,7 @@ static int psb_gem_create(struct drm_file *file,
int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
- args->pitch = ALIGN(args->width & ((args->bpp + 1) / 8), 64);
+ args->pitch = ALIGN(args->width * ((args->bpp + 7) / 8), 64);
args->size = args->pitch * args->height;
return psb_gem_create(file, dev, args->size, &args->handle);
}
diff --git a/drivers/staging/gma500/psb_gtt.c b/drivers/staging/gma500/psb_gtt.c
index 10d772a..dc0a4b7 100644
--- a/drivers/staging/gma500/psb_gtt.c
+++ b/drivers/staging/gma500/psb_gtt.c
@@ -277,7 +277,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
} else {
/* The rest we will use for GEM backed objects */
start = r->start + dev_priv->pg->stolen_size;
- end = -1;
+ end = r->end;
}
gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
prev parent reply other threads:[~2011-05-09 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 15:04 [PATCH 0/2] Further small GMA500 fixes Alan Cox
2011-05-09 15:04 ` [PATCH 1/2] gma500: sort out the file operations Alan Cox
2011-05-09 15:04 ` Alan Cox [this message]
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=20110509150437.28865.72860.stgit@localhost.localdomain \
--to=alan@linux.jf.intel.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®