* [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
@ 2011-10-07 13:26 ` Dan Carpenter
0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-07 13:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Leonid V. Fedorenchik, Mauro Carvalho Chehab, Hans Verkuil,
devel, linux-media, kernel-janitors
If "i" is 2 then when we call cx25821_video_mux() we'd end up going
past the end of the cx25821_boards[dev->board]->input[].
The INPUT() macro obfuscates what's going on in that function so it's
a bit hard to follow.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I don't have this hardware, so I can't actually test this. Please
review this carefully.
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index 084fc08..acd7c4b 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
return err;
}
- if (i > 2) {
+ if (i >= 2) {
dprintk(1, "%s(): -EINVAL\n", __func__);
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
@ 2011-10-07 13:26 ` Dan Carpenter
0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-07 13:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Leonid V. Fedorenchik, Mauro Carvalho Chehab, Hans Verkuil,
devel, linux-media, kernel-janitors
If "i" is 2 then when we call cx25821_video_mux() we'd end up going
past the end of the cx25821_boards[dev->board]->input[].
The INPUT() macro obfuscates what's going on in that function so it's
a bit hard to follow.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I don't have this hardware, so I can't actually test this. Please
review this carefully.
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index 084fc08..acd7c4b 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
return err;
}
- if (i > 2) {
+ if (i >= 2) {
dprintk(1, "%s(): -EINVAL\n", __func__);
return -EINVAL;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
2011-10-07 13:26 ` Dan Carpenter
@ 2011-10-11 20:59 ` Mauro Carvalho Chehab
-1 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2011-10-11 20:59 UTC (permalink / raw)
To: Dan Carpenter
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
Hi Dan,
Em 07-10-2011 10:26, Dan Carpenter escreveu:
> If "i" is 2 then when we call cx25821_video_mux() we'd end up going
> past the end of the cx25821_boards[dev->board]->input[].
>
> The INPUT() macro obfuscates what's going on in that function so it's
> a bit hard to follow.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I don't have this hardware, so I can't actually test this. Please
> review this carefully.
>
> diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
> index 084fc08..acd7c4b 100644
> --- a/drivers/staging/cx25821/cx25821-video.c
> +++ b/drivers/staging/cx25821/cx25821-video.c
> @@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
> return err;
> }
>
> - if (i > 2) {
> + if (i >= 2) {
It would be better to add a NUM_INPUT macro (or something like that, defined together
with the INPUT macro) that would do an ARRAY_SIZE(cx25821_boards) and use it here,
instead of a "2" magic number.
Thanks,
Mauro
> dprintk(1, "%s(): -EINVAL\n", __func__);
> return -EINVAL;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
@ 2011-10-11 20:59 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2011-10-11 20:59 UTC (permalink / raw)
To: Dan Carpenter
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
Hi Dan,
Em 07-10-2011 10:26, Dan Carpenter escreveu:
> If "i" is 2 then when we call cx25821_video_mux() we'd end up going
> past the end of the cx25821_boards[dev->board]->input[].
>
> The INPUT() macro obfuscates what's going on in that function so it's
> a bit hard to follow.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I don't have this hardware, so I can't actually test this. Please
> review this carefully.
>
> diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
> index 084fc08..acd7c4b 100644
> --- a/drivers/staging/cx25821/cx25821-video.c
> +++ b/drivers/staging/cx25821/cx25821-video.c
> @@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
> return err;
> }
>
> - if (i > 2) {
> + if (i >= 2) {
It would be better to add a NUM_INPUT macro (or something like that, defined together
with the INPUT macro) that would do an ARRAY_SIZE(cx25821_boards) and use it here,
instead of a "2" magic number.
Thanks,
Mauro
> dprintk(1, "%s(): -EINVAL\n", __func__);
> return -EINVAL;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
2011-10-11 20:59 ` Mauro Carvalho Chehab
@ 2011-10-12 8:14 ` Dan Carpenter
-1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-12 8:14 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
On Tue, Oct 11, 2011 at 05:59:25PM -0300, Mauro Carvalho Chehab wrote:
> > - if (i > 2) {
> > + if (i >= 2) {
>
> It would be better to add a NUM_INPUT macro (or something like that, defined together
> with the INPUT macro) that would do an ARRAY_SIZE(cx25821_boards) and use it here,
> instead of a "2" magic number.
You're right. The hard coded 2 is not helpful... Why not just an:
if (i >= ARRAY_SIZE(cx25821_boards)) {...
I'll send a patch to do that.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
@ 2011-10-12 8:14 ` Dan Carpenter
0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-12 8:14 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
On Tue, Oct 11, 2011 at 05:59:25PM -0300, Mauro Carvalho Chehab wrote:
> > - if (i > 2) {
> > + if (i >= 2) {
>
> It would be better to add a NUM_INPUT macro (or something like that, defined together
> with the INPUT macro) that would do an ARRAY_SIZE(cx25821_boards) and use it here,
> instead of a "2" magic number.
You're right. The hard coded 2 is not helpful... Why not just an:
if (i >= ARRAY_SIZE(cx25821_boards)) {...
I'll send a patch to do that.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
2011-10-12 8:14 ` Dan Carpenter
@ 2011-10-12 8:29 ` Dan Carpenter
-1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-12 8:29 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
Never mind. I figured out what you meant. I've fixed my patch and
I will send v2 this evening.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input()
@ 2011-10-12 8:29 ` Dan Carpenter
0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-12 8:29 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
Never mind. I figured out what you meant. I've fixed my patch and
I will send v2 this evening.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch v2] Staging: cx25821: off by one in cx25821_vidioc_s_input()
2011-10-11 20:59 ` Mauro Carvalho Chehab
@ 2011-10-13 6:41 ` Dan Carpenter
-1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-13 6:41 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
If "i" is 2 then when we call cx25821_video_mux() we'd end up going
past the end of the cx25821_boards[dev->board]->input[].
The INPUT() macro obfuscates what's going on in that function so it's
a bit hard to follow. And as Mauro points out the hard coded 2 is
not very helpful.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Use a define instead of the hard coded number 2
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index 084fc08..4d6907c 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
return err;
}
- if (i > 2) {
+ if (i >= CX25821_NR_INPUT) {
dprintk(1, "%s(): -EINVAL\n", __func__);
return -EINVAL;
}
diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h
index db2615b..2d2d009 100644
--- a/drivers/staging/cx25821/cx25821.h
+++ b/drivers/staging/cx25821/cx25821.h
@@ -98,6 +98,7 @@
#define CX25821_BOARD_CONEXANT_ATHENA10 1
#define MAX_VID_CHANNEL_NUM 12
#define VID_CHANNEL_NUM 8
+#define CX25821_NR_INPUT 2
struct cx25821_fmt {
char *name;
@@ -196,7 +197,7 @@ struct cx25821_board {
unsigned char radio_addr;
u32 clk_freq;
- struct cx25821_input input[2];
+ struct cx25821_input input[CX25821_NR_INPUT];
};
struct cx25821_subid {
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [patch v2] Staging: cx25821: off by one in cx25821_vidioc_s_input()
@ 2011-10-13 6:41 ` Dan Carpenter
0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-10-13 6:41 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Greg Kroah-Hartman, Leonid V. Fedorenchik, Hans Verkuil, devel,
linux-media, kernel-janitors
If "i" is 2 then when we call cx25821_video_mux() we'd end up going
past the end of the cx25821_boards[dev->board]->input[].
The INPUT() macro obfuscates what's going on in that function so it's
a bit hard to follow. And as Mauro points out the hard coded 2 is
not very helpful.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Use a define instead of the hard coded number 2
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index 084fc08..4d6907c 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -1312,7 +1312,7 @@ int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
return err;
}
- if (i > 2) {
+ if (i >= CX25821_NR_INPUT) {
dprintk(1, "%s(): -EINVAL\n", __func__);
return -EINVAL;
}
diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h
index db2615b..2d2d009 100644
--- a/drivers/staging/cx25821/cx25821.h
+++ b/drivers/staging/cx25821/cx25821.h
@@ -98,6 +98,7 @@
#define CX25821_BOARD_CONEXANT_ATHENA10 1
#define MAX_VID_CHANNEL_NUM 12
#define VID_CHANNEL_NUM 8
+#define CX25821_NR_INPUT 2
struct cx25821_fmt {
char *name;
@@ -196,7 +197,7 @@ struct cx25821_board {
unsigned char radio_addr;
u32 clk_freq;
- struct cx25821_input input[2];
+ struct cx25821_input input[CX25821_NR_INPUT];
};
struct cx25821_subid {
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-10-13 6:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 13:26 [patch] Staging: cx25821: off by on in cx25821_vidioc_s_input() Dan Carpenter
2011-10-07 13:26 ` Dan Carpenter
2011-10-11 20:59 ` Mauro Carvalho Chehab
2011-10-11 20:59 ` Mauro Carvalho Chehab
2011-10-12 8:14 ` Dan Carpenter
2011-10-12 8:14 ` Dan Carpenter
2011-10-12 8:29 ` Dan Carpenter
2011-10-12 8:29 ` Dan Carpenter
2011-10-13 6:41 ` [patch v2] Staging: cx25821: off by one " Dan Carpenter
2011-10-13 6:41 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.