* [patch] drm/nouveau/disp: sizeof() wrong pointer
@ 2013-01-22 7:20 Dan Carpenter
2013-01-22 9:42 ` Paul Menzel
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-01-22 7:20 UTC (permalink / raw)
To: David Airlie; +Cc: kernel-janitors, Ben Skeggs, dri-devel
"data" is a void pointer and "args" is "data" after we have casted it to
a struct. We care about the sizeof the struct here. Btw, sizeof(*data)
is 1.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index ca1a7d7..eb9c489 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -335,7 +335,7 @@ nv50_disp_sync_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head > 1)
+ if (size < sizeof(*args) || args->head > 1)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
@@ -374,7 +374,7 @@ nv50_disp_ovly_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head > 1)
+ if (size < sizeof(*args) || args->head > 1)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
index 9e38ebf..f28725a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
@@ -230,7 +230,7 @@ nvd0_disp_sync_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head >= priv->head.nr)
+ if (size < sizeof(*args) || args->head >= priv->head.nr)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
@@ -270,7 +270,7 @@ nvd0_disp_ovly_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head >= priv->head.nr)
+ if (size < sizeof(*args) || args->head >= priv->head.nr)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] drm/nouveau/disp: sizeof() wrong pointer
2013-01-22 7:20 [patch] drm/nouveau/disp: sizeof() wrong pointer Dan Carpenter
@ 2013-01-22 9:42 ` Paul Menzel
2013-01-23 8:27 ` [patch v2] " Dan Carpenter
2013-01-23 8:38 ` [patch] " Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Paul Menzel @ 2013-01-22 9:42 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, Ben Skeggs, dri-devel
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
Dear Dan,
Am Dienstag, den 22.01.2013, 10:20 +0300 schrieb Dan Carpenter:
> "data" is a void pointer and "args" is "data" after we have casted it to
> a struct. We care about the sizeof the struct here. Btw, sizeof(*data)
s,sizeof the,size of the,
> is 1.
Did you find this by manual inspection or did you use some tool?
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
[…]
With the typo fixed above,
Acked-by: Paul Menzel <paulepanter@users.sourceforge.net>
Thanks,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch v2] drm/nouveau/disp: sizeof() wrong pointer
2013-01-22 9:42 ` Paul Menzel
@ 2013-01-23 8:27 ` Dan Carpenter
2013-01-23 8:38 ` [patch] " Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2013-01-23 8:27 UTC (permalink / raw)
To: David Airlie; +Cc: kernel-janitors, Ben Skeggs, dri-devel, Paul Menzel
"data" is a void pointer and "args" is "data" after we have casted it to
a struct. We care about the size of the struct here. Btw,
sizeof(*data) is 1.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: tweaked the commit message
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index ca1a7d7..eb9c489 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -335,7 +335,7 @@ nv50_disp_sync_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head > 1)
+ if (size < sizeof(*args) || args->head > 1)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
@@ -374,7 +374,7 @@ nv50_disp_ovly_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head > 1)
+ if (size < sizeof(*args) || args->head > 1)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
index 9e38ebf..f28725a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
@@ -230,7 +230,7 @@ nvd0_disp_sync_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head >= priv->head.nr)
+ if (size < sizeof(*args) || args->head >= priv->head.nr)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
@@ -270,7 +270,7 @@ nvd0_disp_ovly_ctor(struct nouveau_object *parent,
struct nv50_disp_dmac *dmac;
int ret;
- if (size < sizeof(*data) || args->head >= priv->head.nr)
+ if (size < sizeof(*args) || args->head >= priv->head.nr)
return -EINVAL;
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] drm/nouveau/disp: sizeof() wrong pointer
2013-01-22 9:42 ` Paul Menzel
2013-01-23 8:27 ` [patch v2] " Dan Carpenter
@ 2013-01-23 8:38 ` Dan Carpenter
2013-01-23 11:36 ` Bernd Petrovitsch
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-01-23 8:38 UTC (permalink / raw)
To: Paul Menzel; +Cc: kernel-janitors, Ben Skeggs, dri-devel
On Tue, Jan 22, 2013 at 10:42:25AM +0100, Paul Menzel wrote:
>
> Did you find this by manual inspection or did you use some tool?
>
I found this because it caused a problem in a parser I was working
on but Sparse warns about "warning: expression using sizeof(void)".
It's sort of hard to run Sparse on nouveau because you can't build
the individual .o files.
$ kchecker --sparse drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
<stdin>:1223:2: warning: #warning syscall finit_module not implemented [-Wcpp]
scripts/Makefile.build:44: /home/dcarpenter/progs/kernel/devel/drivers/gpu/drm/nouveau/core/engine/disp/Makefile: No such file or directory
make[1]: *** No rule to make target `/home/dcarpenter/progs/kernel/devel/drivers/gpu/drm/nouveau/core/engine/disp/Makefile'. Stop.
make: *** [drivers/gpu/drm/nouveau/core/engine/disp/nv50.o] Error 2
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] drm/nouveau/disp: sizeof() wrong pointer
2013-01-23 8:38 ` [patch] " Dan Carpenter
@ 2013-01-23 11:36 ` Bernd Petrovitsch
0 siblings, 0 replies; 5+ messages in thread
From: Bernd Petrovitsch @ 2013-01-23 11:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, Paul Menzel, dri-devel, Ben Skeggs
On Mit, 2013-01-23 at 11:38 +0300, Dan Carpenter wrote:
> On Tue, Jan 22, 2013 at 10:42:25AM +0100, Paul Menzel wrote:
> >
> > Did you find this by manual inspection or did you use some tool?
>
> I found this because it caused a problem in a parser I was working
> on but Sparse warns about "warning: expression using sizeof(void)".
gcc's -Wpointer-arith option also reports this.
Never tried it on the kernel though .....
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-23 11:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 7:20 [patch] drm/nouveau/disp: sizeof() wrong pointer Dan Carpenter
2013-01-22 9:42 ` Paul Menzel
2013-01-23 8:27 ` [patch v2] " Dan Carpenter
2013-01-23 8:38 ` [patch] " Dan Carpenter
2013-01-23 11:36 ` Bernd Petrovitsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox