Commit f92e8834 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

gma500: Fix dumb create crash

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ea1ce376
...@@ -100,8 +100,8 @@ static int psb_gem_create(struct drm_file *file, ...@@ -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 /* Allocate our object - for now a direct gtt range which is not
stolen memory backed */ stolen memory backed */
r = psb_gtt_alloc_range(dev, size, "gem", 0); r = psb_gtt_alloc_range(dev, size, "gem", 0);
if (IS_ERR(r)) if (r == NULL)
return PTR_ERR(r); return -ENOSPC;
/* Initialize the extra goodies GEM needs to do all the hard work */ /* Initialize the extra goodies GEM needs to do all the hard work */
if (drm_gem_object_init(dev, &r->gem, size) != 0) { if (drm_gem_object_init(dev, &r->gem, size) != 0) {
psb_gtt_free_range(dev, r); psb_gtt_free_range(dev, r);
...@@ -135,7 +135,7 @@ static int psb_gem_create(struct drm_file *file, ...@@ -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, int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args) 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; args->size = args->pitch * args->height;
return psb_gem_create(file, dev, args->size, &args->handle); return psb_gem_create(file, dev, args->size, &args->handle);
} }
......
...@@ -277,7 +277,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len, ...@@ -277,7 +277,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
} else { } else {
/* The rest we will use for GEM backed objects */ /* The rest we will use for GEM backed objects */
start = r->start + dev_priv->pg->stolen_size; start = r->start + dev_priv->pg->stolen_size;
end = -1; end = r->end;
} }
gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL); gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment