linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-buf: heaps: bugfix for selftest failure
@ 2020-03-04  5:34 Leon He
  2020-03-13 16:10 ` shuah
  0 siblings, 1 reply; 3+ messages in thread
From: Leon He @ 2020-03-04  5:34 UTC (permalink / raw)
  To: shuah, sumit.semwal
  Cc: linux-kselftest, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig, Leon He

If the 'name' array in check_vgem() was not initialized to null, the
value of name[4] may be random. Which will cause strcmp(name, "vgem")
failed.

Signed-off-by: Leon He <leon.he@unisoc.com>
---
 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index cd5e1f6..21f3d19 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -22,7 +22,7 @@
 static int check_vgem(int fd)
 {
 	drm_version_t version = { 0 };
-	char name[5];
+	char name[5] = { 0 };
 	int ret;
 
 	version.name_len = 4;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: heaps: bugfix for selftest failure
  2020-03-04  5:34 [PATCH] dma-buf: heaps: bugfix for selftest failure Leon He
@ 2020-03-13 16:10 ` shuah
  2020-03-18  2:19   ` xiaolong he
  0 siblings, 1 reply; 3+ messages in thread
From: shuah @ 2020-03-13 16:10 UTC (permalink / raw)
  To: Leon He, sumit.semwal
  Cc: linux-kselftest, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig, Leon He, shuah

On 3/3/20 10:34 PM, Leon He wrote:
> If the 'name' array in check_vgem() was not initialized to null, the
> value of name[4] may be random. Which will cause strcmp(name, "vgem")
> failed.

Nit: "to fail" instead of "failed"


> 
> Signed-off-by: Leon He <leon.he@unisoc.com>
> ---
>   tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index cd5e1f6..21f3d19 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -22,7 +22,7 @@
>   static int check_vgem(int fd)
>   {
>   	drm_version_t version = { 0 };
> -	char name[5];
> +	char name[5] = { 0 };
>   	int ret;
>   
>   	version.name_len = 4;
> 

return !strcmp(name, "vgem");

While you are at it, why not change strcmp() to strncmp()?

thanks,
-- Shuah



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: heaps: bugfix for selftest failure
  2020-03-13 16:10 ` shuah
@ 2020-03-18  2:19   ` xiaolong he
  0 siblings, 0 replies; 3+ messages in thread
From: xiaolong he @ 2020-03-18  2:19 UTC (permalink / raw)
  To: shuah
  Cc: Sumit Semwal, linux-kselftest, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig, Leon He

>
> On 3/3/20 10:34 PM, Leon He wrote:
> > If the 'name' array in check_vgem() was not initialized to null, the
> > value of name[4] may be random. Which will cause strcmp(name, "vgem")
> > failed.
>
> Nit: "to fail" instead of "failed"

OK, thanks!

>
>
> >
> > Signed-off-by: Leon He <leon.he@unisoc.com>
> > ---
> >   tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> > index cd5e1f6..21f3d19 100644
> > --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> > +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> > @@ -22,7 +22,7 @@
> >   static int check_vgem(int fd)
> >   {
> >       drm_version_t version = { 0 };
> > -     char name[5];
> > +     char name[5] = { 0 };
> >       int ret;
> >
> >       version.name_len = 4;
> >
>
> return !strcmp(name, "vgem");
>
> While you are at it, why not change strcmp() to strncmp()?
>

OK, I'll change it in patch v3.

thanks,
-- Leon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-18  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  5:34 [PATCH] dma-buf: heaps: bugfix for selftest failure Leon He
2020-03-13 16:10 ` shuah
2020-03-18  2:19   ` xiaolong he

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).