* Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 7:37 [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value Xidong Wang
@ 2018-04-04 7:56 ` Chris Wilson
2018-04-04 9:38 ` [RESEND] drm/i915: Do no use kfree() to free a " Chris Wilson
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2018-04-04 7:56 UTC (permalink / raw)
To: Xidong Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Xidong Wang
Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
That is indeed what it should be doing,
Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 7:56 ` Chris Wilson
0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2018-04-04 7:56 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: Xidong Wang, intel-gfx, linux-kernel, dri-devel
Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
That is indeed what it should be doing,
Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 17+ messages in thread
* [RESEND] drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
2018-04-04 7:37 [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value Xidong Wang
2018-04-04 7:56 ` Chris Wilson
@ 2018-04-04 9:38 ` Chris Wilson
2018-04-04 10:32 ` ✓ Fi.CI.BAT: success for " Patchwork
` (2 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2018-04-04 9:38 UTC (permalink / raw)
To: intel-gfx; +Cc: Xidong Wang, Chris Wilson, Tvrtko Ursulin, stable
From: Xidong Wang <wangxidong_97@163.com>
Along the eb_lookup_vmas() error path, the return value from
kmem_cache_alloc() was freed using kfree(). Fix it to use the proper
kmem_cache_free() instead.
Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Signed-off-by: Xidong Wang <wangxidong_97@163.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8c170db8495d..0414228cd2b5 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -728,7 +728,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
err = radix_tree_insert(handles_vma, handle, vma);
if (unlikely(err)) {
- kfree(lut);
+ kmem_cache_free(eb->i915->luts, lut);
goto err_obj;
}
--
2.16.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* ✓ Fi.CI.BAT: success for drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
2018-04-04 7:37 [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value Xidong Wang
2018-04-04 7:56 ` Chris Wilson
2018-04-04 9:38 ` [RESEND] drm/i915: Do no use kfree() to free a " Chris Wilson
@ 2018-04-04 10:32 ` Patchwork
2018-04-04 11:51 ` ✓ Fi.CI.IGT: " Patchwork
2018-04-04 20:54 ` Chris Wilson
4 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2018-04-04 10:32 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
URL : https://patchwork.freedesktop.org/series/41130/
State : success
== Summary ==
Series 41130v1 drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
https://patchwork.freedesktop.org/api/1.0/series/41130/revisions/1/mbox/
---- Possible new issues:
Test gem_exec_gttfill:
Subgroup basic:
skip -> PASS (fi-pnv-d510)
---- Known issues:
Test kms_chamelium:
Subgroup dp-edid-read:
pass -> FAIL (fi-kbl-7500u) fdo#102505
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-c:
fail -> PASS (fi-skl-guc) fdo#103191
fdo#102505 https://bugs.freedesktop.org/show_bug.cgi?id=102505
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:431s
fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:442s
fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:380s
fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:538s
fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:297s
fi-bxt-dsi total:285 pass:255 dwarn:0 dfail:0 fail:0 skip:30 time:512s
fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:515s
fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:522s
fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:509s
fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:411s
fi-cfl-s3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:557s
fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:511s
fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:592s
fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:425s
fi-gdg-551 total:285 pass:176 dwarn:0 dfail:0 fail:1 skip:108 time:316s
fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:539s
fi-glk-j4005 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:482s
fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:404s
fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:420s
fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:469s
fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:431s
fi-kbl-7500u total:285 pass:259 dwarn:1 dfail:0 fail:1 skip:24 time:477s
fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:467s
fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:512s
fi-pnv-d510 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:665s
fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:438s
fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:534s
fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:499s
fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:496s
fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:433s
fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:445s
fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:565s
fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:407s
Blacklisted hosts:
fi-cnl-psr total:285 pass:256 dwarn:3 dfail:0 fail:0 skip:26 time:536s
1c1f24f54234a760e02c8aac04a5714ae63fa2f0 drm-tip: 2018y-04m-04d-08h-24m-53s UTC integration manifest
89b0fef5317c drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8577/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 17+ messages in thread
* ✓ Fi.CI.IGT: success for drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
2018-04-04 7:37 [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value Xidong Wang
` (2 preceding siblings ...)
2018-04-04 10:32 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-04-04 11:51 ` Patchwork
2018-04-04 20:54 ` Chris Wilson
4 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2018-04-04 11:51 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Do no use kfree() to free a kmem_cache_alloc() return value
URL : https://patchwork.freedesktop.org/series/41130/
State : success
== Summary ==
---- Possible new issues:
Test kms_cursor_crc:
Subgroup cursor-64x64-random:
skip -> PASS (shard-snb)
Test kms_frontbuffer_tracking:
Subgroup fbc-2p-scndscrn-cur-indfb-draw-mmap-gtt:
skip -> PASS (shard-hsw)
Subgroup fbc-2p-scndscrn-cur-indfb-draw-mmap-wc:
skip -> PASS (shard-hsw)
Subgroup fbc-2p-scndscrn-indfb-plflip-blt:
skip -> PASS (shard-hsw)
---- Known issues:
Test kms_cursor_legacy:
Subgroup flip-vs-cursor-varying-size:
fail -> PASS (shard-hsw) fdo#102670
Test kms_flip:
Subgroup modeset-vs-vblank-race-interruptible:
pass -> FAIL (shard-hsw) fdo#103060 +1
Subgroup plain-flip-fb-recreate:
fail -> PASS (shard-hsw) fdo#100368
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-shrfb-pgflip-blt:
pass -> DMESG-FAIL (shard-apl) fdo#105685
Test kms_vblank:
Subgroup pipe-c-query-forked-busy:
dmesg-warn -> PASS (shard-hsw) fdo#102614
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#105685 https://bugs.freedesktop.org/show_bug.cgi?id=105685
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
shard-apl total:3498 pass:1834 dwarn:1 dfail:1 fail:7 skip:1655 time:12930s
shard-hsw total:3498 pass:1783 dwarn:1 dfail:0 fail:3 skip:1710 time:11523s
shard-snb total:3498 pass:1377 dwarn:1 dfail:0 fail:2 skip:2118 time:7073s
Blacklisted hosts:
shard-kbl total:3480 pass:1944 dwarn:1 dfail:0 fail:6 skip:1528 time:9046s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8577/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 7:37 [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value Xidong Wang
@ 2018-04-04 20:54 ` Chris Wilson
2018-04-04 9:38 ` [RESEND] drm/i915: Do no use kfree() to free a " Chris Wilson
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2018-04-04 20:54 UTC (permalink / raw)
To: Xidong Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Xidong Wang
Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
Thank you for the fix; applied.
-Chris
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 20:54 ` Chris Wilson
0 siblings, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2018-04-04 20:54 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Xidong Wang
Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
Thank you for the fix; applied.
-Chris
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 6:37 [PATCH 1/1] drm/i915:Do " Xidong Wang
@ 2018-04-04 8:16 ` Jani Nikula
2018-04-04 13:02 ` kbuild test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: Jani Nikula @ 2018-04-04 8:16 UTC (permalink / raw)
To: Xidong Wang, Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Xidong Wang
On Wed, 04 Apr 2018, Xidong Wang <wangxidong_97@163.com> wrote:
> In eb_lookup_vmas(), lut, the return value of kmem_cache_alloc(), is freed
> with kfree().I think the expected paired function is kmem_cache_free().
Agreed. But did you try to compile your patch before sending?
Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
BR,
Jani.
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
> ---
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 8c170db..08fe476 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -728,7 +728,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
>
> err = radix_tree_insert(handles_vma, handle, vma);
> if (unlikely(err)) {
> - kfree(lut);
> + kmem_cache_free(lut);
> goto err_obj;
> }
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 8:16 ` Jani Nikula
0 siblings, 0 replies; 17+ messages in thread
From: Jani Nikula @ 2018-04-04 8:16 UTC (permalink / raw)
To: Joonas Lahtinen, Rodrigo Vivi, David Airlie
Cc: Xidong Wang, intel-gfx, linux-kernel, dri-devel
On Wed, 04 Apr 2018, Xidong Wang <wangxidong_97@163.com> wrote:
> In eb_lookup_vmas(), lut, the return value of kmem_cache_alloc(), is freed
> with kfree().I think the expected paired function is kmem_cache_free().
Agreed. But did you try to compile your patch before sending?
Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.14+
BR,
Jani.
>
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
> ---
> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 8c170db..08fe476 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -728,7 +728,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
>
> err = radix_tree_insert(handles_vma, handle, vma);
> if (unlikely(err)) {
> - kfree(lut);
> + kmem_cache_free(lut);
> goto err_obj;
> }
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 6:37 [PATCH 1/1] drm/i915:Do " Xidong Wang
@ 2018-04-04 13:02 ` kbuild test robot
2018-04-04 13:02 ` kbuild test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:02 UTC (permalink / raw)
To: Xidong Wang
Cc: kbuild-all, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel, linux-kernel, Xidong Wang
[-- Attachment #1: Type: text/plain, Size: 4882 bytes --]
Hi Xidong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-a1-201813 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
drivers/gpu//drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:20: warning: passing argument 1 of 'kmem_cache_free' from incompatible pointer type
kmem_cache_free(lut);
^
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^
drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^
vim +/kmem_cache_free +731 drivers/gpu//drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26952 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 13:02 ` kbuild test robot
0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:02 UTC (permalink / raw)
Cc: dri-devel, David Airlie, intel-gfx, linux-kernel, Xidong Wang,
kbuild-all, Rodrigo Vivi
[-- Attachment #1: Type: text/plain, Size: 4882 bytes --]
Hi Xidong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-a1-201813 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
drivers/gpu//drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:20: warning: passing argument 1 of 'kmem_cache_free' from incompatible pointer type
kmem_cache_free(lut);
^
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^
drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^
vim +/kmem_cache_free +731 drivers/gpu//drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26952 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 6:37 [PATCH 1/1] drm/i915:Do " Xidong Wang
@ 2018-04-04 13:24 ` kbuild test robot
2018-04-04 13:02 ` kbuild test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:24 UTC (permalink / raw)
To: Xidong Wang
Cc: kbuild-all, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel, linux-kernel, Xidong Wang
Hi Xidong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: sparse: incorrect type in argument 1 (different base types) @@ expected struct kmem_cache *<noident> @@ got struct i915_lut_struct kmem_cache *<noident> @@
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: expected struct kmem_cache *<noident>
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: got struct i915_lut_handle *[assigned] lut
>> drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:40: sparse: not enough arguments for function kmem_cache_free
drivers/gpu/drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:20: error: passing argument 1 of 'kmem_cache_free' from incompatible pointer type [-Werror=incompatible-pointer-types]
kmem_cache_free(lut);
^~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu/drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^~~~~~~~~~~~~~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu/drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +731 drivers/gpu/drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 13:24 ` kbuild test robot
0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:24 UTC (permalink / raw)
Cc: kbuild-all, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel, linux-kernel, Xidong Wang
Hi Xidong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: sparse: incorrect type in argument 1 (different base types) @@ expected struct kmem_cache *<noident> @@ got struct i915_lut_struct kmem_cache *<noident> @@
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: expected struct kmem_cache *<noident>
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:41: got struct i915_lut_handle *[assigned] lut
>> drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:40: sparse: not enough arguments for function kmem_cache_free
drivers/gpu/drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:20: error: passing argument 1 of 'kmem_cache_free' from incompatible pointer type [-Werror=incompatible-pointer-types]
kmem_cache_free(lut);
^~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu/drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
drivers/gpu/drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^~~~~~~~~~~~~~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu/drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +731 drivers/gpu/drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
2018-04-04 6:37 [PATCH 1/1] drm/i915:Do " Xidong Wang
@ 2018-04-04 13:44 ` kbuild test robot
2018-04-04 13:02 ` kbuild test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:44 UTC (permalink / raw)
To: Xidong Wang
Cc: kbuild-all, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel, linux-kernel, Xidong Wang
[-- Attachment #1: Type: text/plain, Size: 4997 bytes --]
Hi Xidong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x009-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/gpu//drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:20: error: passing argument 1 of 'kmem_cache_free' from incompatible pointer type [-Werror=incompatible-pointer-types]
kmem_cache_free(lut);
^~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^~~~~~~~~~~~~~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/kmem_cache_free +731 drivers/gpu//drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30028 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/1] drm/i915:Do not use kfree() to free kmem_cache_alloc() return value
@ 2018-04-04 13:44 ` kbuild test robot
0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-04 13:44 UTC (permalink / raw)
Cc: kbuild-all, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel, linux-kernel, Xidong Wang
[-- Attachment #1: Type: text/plain, Size: 4997 bytes --]
Hi Xidong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Xidong-Wang/drm-i915-Do-not-use-kfree-to-free-kmem_cache_alloc-return-value/20180404-193341
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x009-201813 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/gpu//drm/i915/i915_gem_execbuffer.c: In function 'eb_lookup_vmas':
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:20: error: passing argument 1 of 'kmem_cache_free' from incompatible pointer type [-Werror=incompatible-pointer-types]
kmem_cache_free(lut);
^~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: expected 'struct kmem_cache *' but argument is of type 'struct i915_lut_handle *'
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
>> drivers/gpu//drm/i915/i915_gem_execbuffer.c:731:4: error: too few arguments to function 'kmem_cache_free'
kmem_cache_free(lut);
^~~~~~~~~~~~~~~
In file included from include/linux/reservation.h:44:0,
from drivers/gpu//drm/i915/i915_gem_execbuffer.c:30:
include/linux/slab.h:356:6: note: declared here
void kmem_cache_free(struct kmem_cache *, void *);
^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/kmem_cache_free +731 drivers/gpu//drm/i915/i915_gem_execbuffer.c
685
686 static int eb_lookup_vmas(struct i915_execbuffer *eb)
687 {
688 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
689 struct drm_i915_gem_object *obj;
690 unsigned int i;
691 int err;
692
693 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
694 return -ENOENT;
695
696 if (unlikely(i915_gem_context_is_banned(eb->ctx)))
697 return -EIO;
698
699 INIT_LIST_HEAD(&eb->relocs);
700 INIT_LIST_HEAD(&eb->unbound);
701
702 for (i = 0; i < eb->buffer_count; i++) {
703 u32 handle = eb->exec[i].handle;
704 struct i915_lut_handle *lut;
705 struct i915_vma *vma;
706
707 vma = radix_tree_lookup(handles_vma, handle);
708 if (likely(vma))
709 goto add_vma;
710
711 obj = i915_gem_object_lookup(eb->file, handle);
712 if (unlikely(!obj)) {
713 err = -ENOENT;
714 goto err_vma;
715 }
716
717 vma = i915_vma_instance(obj, eb->vm, NULL);
718 if (unlikely(IS_ERR(vma))) {
719 err = PTR_ERR(vma);
720 goto err_obj;
721 }
722
723 lut = kmem_cache_alloc(eb->i915->luts, GFP_KERNEL);
724 if (unlikely(!lut)) {
725 err = -ENOMEM;
726 goto err_obj;
727 }
728
729 err = radix_tree_insert(handles_vma, handle, vma);
730 if (unlikely(err)) {
> 731 kmem_cache_free(lut);
732 goto err_obj;
733 }
734
735 /* transfer ref to ctx */
736 vma->open_count++;
737 list_add(&lut->obj_link, &obj->lut_list);
738 list_add(&lut->ctx_link, &eb->ctx->handles_list);
739 lut->ctx = eb->ctx;
740 lut->handle = handle;
741
742 add_vma:
743 err = eb_add_vma(eb, i, vma);
744 if (unlikely(err))
745 goto err_vma;
746
747 GEM_BUG_ON(vma != eb->vma[i]);
748 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
749 }
750
751 /* take note of the batch buffer before we might reorder the lists */
752 i = eb_batch_index(eb);
753 eb->batch = eb->vma[i];
754 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
755
756 /*
757 * SNA is doing fancy tricks with compressing batch buffers, which leads
758 * to negative relocation deltas. Usually that works out ok since the
759 * relocate address is still positive, except when the batch is placed
760 * very low in the GTT. Ensure this doesn't happen.
761 *
762 * Note that actual hangs have only been observed on gen7, but for
763 * paranoia do it everywhere.
764 */
765 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
766 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
767 if (eb->reloc_cache.has_fence)
768 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
769
770 eb->args->flags |= __EXEC_VALIDATED;
771 return eb_reserve(eb);
772
773 err_obj:
774 i915_gem_object_put(obj);
775 err_vma:
776 eb->vma[i] = NULL;
777 return err;
778 }
779
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30028 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread