diff options
| -rw-r--r-- | drivers/gpu/drm/i915/i915_gpu_error.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 8c81cf3aa182..1175fec08fe1 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c | |||
| @@ -1391,15 +1391,20 @@ static void request_record_user_bo(struct i915_request *request, | |||
| 1391 | { | 1391 | { |
| 1392 | struct i915_capture_list *c; | 1392 | struct i915_capture_list *c; |
| 1393 | struct drm_i915_error_object **bo; | 1393 | struct drm_i915_error_object **bo; |
| 1394 | long count; | 1394 | long count, max; |
| 1395 | 1395 | ||
| 1396 | count = 0; | 1396 | max = 0; |
| 1397 | for (c = request->capture_list; c; c = c->next) | 1397 | for (c = request->capture_list; c; c = c->next) |
| 1398 | count++; | 1398 | max++; |
| 1399 | if (!max) | ||
| 1400 | return; | ||
| 1399 | 1401 | ||
| 1400 | bo = NULL; | 1402 | bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC); |
| 1401 | if (count) | 1403 | if (!bo) { |
| 1402 | bo = kcalloc(count, sizeof(*bo), GFP_ATOMIC); | 1404 | /* If we can't capture everything, try to capture something. */ |
| 1405 | max = min_t(long, max, PAGE_SIZE / sizeof(*bo)); | ||
| 1406 | bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC); | ||
| 1407 | } | ||
| 1403 | if (!bo) | 1408 | if (!bo) |
| 1404 | return; | 1409 | return; |
| 1405 | 1410 | ||
| @@ -1408,7 +1413,8 @@ static void request_record_user_bo(struct i915_request *request, | |||
| 1408 | bo[count] = i915_error_object_create(request->i915, c->vma); | 1413 | bo[count] = i915_error_object_create(request->i915, c->vma); |
| 1409 | if (!bo[count]) | 1414 | if (!bo[count]) |
| 1410 | break; | 1415 | break; |
| 1411 | count++; | 1416 | if (++count == max) |
| 1417 | break; | ||
| 1412 | } | 1418 | } |
| 1413 | 1419 | ||
| 1414 | ee->user_bo = bo; | 1420 | ee->user_bo = bo; |
