Skip to contentSkip to conversation

drm/radeon: add a check for allocation failure

PATCH In review Dan Carpenter 3 participants 4 messages Aug 7, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: add a check for allocation failure

We can easily return -ENOMEM here if kzalloc() fails.

drivers/gpu/drm/radeon/radeon_vm.c +2 -0
index ccae4d9..d15d987 100644
@@ -483,6 +483,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
 			/* add a clone of the bo_va to clear the old address */
 			struct radeon_bo_va *tmp;
 			tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL);
+			if (!tmp)
+				return -ENOMEM;
 			tmp->it.start = bo_va->it.start;
 			tmp->it.last = bo_va->it.last;
 			tmp->vm = vm;
#1 lore raw
Quoted 9 lines · Dan Carpenter

We can easily return -ENOMEM here if kzalloc() fails.

drivers/gpu/drm/radeon/radeon_vm.c +0 -0
index ccae4d9..d15d987 100644

drivers/gpu/drm/radeon/radeon_vm.c int radeon_vm_bo_set_addr(struct radeon_device *rdev, · line 487

Quoted 5 lines
drivers/gpu/drm/radeon/radeon_vm.c +2 -0
@@ -483,6 +483,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
                        /* add a clone of the bo_va to clear the old address */
                        struct radeon_bo_va *tmp;
                        tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL);
+                       if (!tmp)
+                               return -ENOMEM;

We need to drop the lock here too. I'll apply and fix it up. Thanks!

Alex

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_vm.c +0 -0
                        tmp->it.start = bo_va->it.start;
                        tmp->it.last = bo_va->it.last;
                        tmp->vm = vm;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#2 lore raw

I'm 100% sure that I've fixed that as well with a follow up patch. Looks like that one didn't made it into 3.17

Christian.

Am 07.08.2014 um 17:31 schrieb Alex Deucher:

Quoted 26 lines · Dan Carpenter
Quoted 9 lines

We can easily return -ENOMEM here if kzalloc() fails.

drivers/gpu/drm/radeon/radeon_vm.c +0 -0
index ccae4d9..d15d987 100644

drivers/gpu/drm/radeon/radeon_vm.c int radeon_vm_bo_set_addr(struct radeon_device *rdev, · line 487

Quoted 5 lines
drivers/gpu/drm/radeon/radeon_vm.c +2 -0
@@ -483,6 +483,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
                         /* add a clone of the bo_va to clear the old address */
                         struct radeon_bo_va *tmp;
                         tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL);
+                       if (!tmp)
+                               return -ENOMEM;

We need to drop the lock here too. I'll apply and fix it up. Thanks!

Alex

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_vm.c +0 -0
                         tmp->it.start = bo_va->it.start;
                         tmp->it.last = bo_va->it.last;
                         tmp->vm = vm;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Alex Deucher
Quoted 5 lines · Alex Deucher
Quoted 4 lines · Dan Carpenter

We can easily return -ENOMEM here if kzalloc() fails.

Quoted 13 lines

drivers/gpu/drm/radeon/radeon_vm.c int radeon_vm_bo_set_addr(struct radeon_device *rdev, · line 487

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_vm.c +2 -0
index ccae4d9..d15d987 100644
@@ -483,6 +483,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
                        /* add a clone of the bo_va to clear the old address */
                        struct radeon_bo_va *tmp;
                        tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL);
+                       if (!tmp)
+                               return -ENOMEM;

We need to drop the lock here too. I'll apply and fix it up. Thanks!

Gar. I'm sorry. I thought it looked easier than it was.

Also I really should have caught that in my qc. :/ I'm not sure what happened.

regards,
dan carpenter