Unverified Commit 778fa8ad authored by Dan Carpenter's avatar Dan Carpenter Committed by Rodrigo Vivi
Browse files

drm/i915/selftests: Change mock_request() to return error pointers



There was an error pointer vs NULL bug in __igt_breadcrumbs_smoketest().
The __mock_request_alloc() function implements the
smoketest->request_alloc() function pointer.  It was supposed to return
error pointers, but it propogates the NULL return from mock_request()
so in the event of a failure, it would lead to a NULL pointer
dereference.

To fix this, change the mock_request() function to return error pointers
and update all the callers to expect that.

Fixes: 52c0fdb2 ("drm/i915: Replace global breadcrumbs with per-context interrupt tracking")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/685c1417.050a0220.696f5.5c05@mx.google.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 7c377900
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -73,8 +73,8 @@ static int igt_add_request(void *arg)
	/* Basic preliminary test to create a request and let it loose! */

	request = mock_request(rcs0(i915)->kernel_context, HZ / 10);
	if (!request)
		return -ENOMEM;
	if (IS_ERR(request))
		return PTR_ERR(request);

	i915_request_add(request);

@@ -91,8 +91,8 @@ static int igt_wait_request(void *arg)
	/* Submit a request, then wait upon it */

	request = mock_request(rcs0(i915)->kernel_context, T);
	if (!request)
		return -ENOMEM;
	if (IS_ERR(request))
		return PTR_ERR(request);

	i915_request_get(request);

@@ -160,8 +160,8 @@ static int igt_fence_wait(void *arg)
	/* Submit a request, treat it as a fence and wait upon it */

	request = mock_request(rcs0(i915)->kernel_context, T);
	if (!request)
		return -ENOMEM;
	if (IS_ERR(request))
		return PTR_ERR(request);

	if (dma_fence_wait_timeout(&request->fence, false, T) != -ETIME) {
		pr_err("fence wait success before submit (expected timeout)!\n");
@@ -219,8 +219,8 @@ static int igt_request_rewind(void *arg)
	GEM_BUG_ON(IS_ERR(ce));
	request = mock_request(ce, 2 * HZ);
	intel_context_put(ce);
	if (!request) {
		err = -ENOMEM;
	if (IS_ERR(request)) {
		err = PTR_ERR(request);
		goto err_context_0;
	}

@@ -237,8 +237,8 @@ static int igt_request_rewind(void *arg)
	GEM_BUG_ON(IS_ERR(ce));
	vip = mock_request(ce, 0);
	intel_context_put(ce);
	if (!vip) {
		err = -ENOMEM;
	if (IS_ERR(vip)) {
		err = PTR_ERR(vip);
		goto err_context_1;
	}

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ mock_request(struct intel_context *ce, unsigned long delay)
	/* NB the i915->requests slab cache is enlarged to fit mock_request */
	request = intel_context_create_request(ce);
	if (IS_ERR(request))
		return NULL;
		return request;

	request->mock.delay = delay;
	return request;