diff mbox

cx25821: Remove bad strcpy to read-only char*

Message ID 1342633271-5731-1-git-send-email-elezegarcia@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ezequiel Garcia July 18, 2012, 5:41 p.m. UTC
The strcpy was being used to set the name of the board.
This was both wrong and redundant,
since the destination char* was read-only and
the name is set statically at compile time.

The type of the name field is changed to const char*
to prevent future errors.

Reported-by: Radek Masin <radek@masin.eu>
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
---
Hi Mauro,

I believe without this patch cx25821 driver
is completely unusable.

So perhaps this patch should also go to stable tree?
I'm a bit unsure about this procedure.

Regards,
Ezequiel.
 
---
 drivers/media/video/cx25821/cx25821-core.c |    3 ---
 drivers/media/video/cx25821/cx25821.h      |    2 +-
 2 files changed, 1 insertions(+), 4 deletions(-)

Comments

Hans Verkuil July 19, 2012, 11:17 a.m. UTC | #1
Ezequiel,

Can you post this patch again, but this time to Linus Torvalds as well?

See e.g. http://www.spinics.net/lists/linux-media/msg50407.html how I did that.

It would be good to have this fixed in 3.5. I'm afraid that by the time
Mauro is back 3.5 will be released and this is a nasty bug.

Regards,

	Hans

On Wed 18 July 2012 19:41:11 Ezequiel Garcia wrote:
> The strcpy was being used to set the name of the board.
> This was both wrong and redundant,
> since the destination char* was read-only and
> the name is set statically at compile time.
> 
> The type of the name field is changed to const char*
> to prevent future errors.
> 
> Reported-by: Radek Masin <radek@masin.eu>
> Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
> ---
> Hi Mauro,
> 
> I believe without this patch cx25821 driver
> is completely unusable.
> 
> So perhaps this patch should also go to stable tree?
> I'm a bit unsure about this procedure.
> 
> Regards,
> Ezequiel.
>  
> ---
>  drivers/media/video/cx25821/cx25821-core.c |    3 ---
>  drivers/media/video/cx25821/cx25821.h      |    2 +-
>  2 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/video/cx25821/cx25821-core.c b/drivers/media/video/cx25821/cx25821-core.c
> index 83c1aa6..f11f6f0 100644
> --- a/drivers/media/video/cx25821/cx25821-core.c
> +++ b/drivers/media/video/cx25821/cx25821-core.c
> @@ -904,9 +904,6 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
>  	list_add_tail(&dev->devlist, &cx25821_devlist);
>  	mutex_unlock(&cx25821_devlist_mutex);
>  
> -	strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
> -	strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
> -
>  	if (dev->pci->device != 0x8210) {
>  		pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
>  			__func__, dev->pci->device);
> diff --git a/drivers/media/video/cx25821/cx25821.h b/drivers/media/video/cx25821/cx25821.h
> index b9aa801..029f293 100644
> --- a/drivers/media/video/cx25821/cx25821.h
> +++ b/drivers/media/video/cx25821/cx25821.h
> @@ -187,7 +187,7 @@ enum port {
>  };
>  
>  struct cx25821_board {
> -	char *name;
> +	const char *name;
>  	enum port porta;
>  	enum port portb;
>  	enum port portc;
> 
--
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
Ezequiel Garcia July 19, 2012, 1:32 p.m. UTC | #2
On Thu, Jul 19, 2012 at 8:17 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Ezequiel,
>
> Can you post this patch again, but this time to Linus Torvalds as well?
>
> See e.g. http://www.spinics.net/lists/linux-media/msg50407.html how I did that.
>
> It would be good to have this fixed in 3.5. I'm afraid that by the time
> Mauro is back 3.5 will be released and this is a nasty bug.
>

Okey, I'll do that. Shouldn't this go to stable also?

Thanks for your help,
Ezequiel.
--
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
Hans Verkuil July 19, 2012, 1:41 p.m. UTC | #3
On Thu 19 July 2012 15:32:21 Ezequiel Garcia wrote:
> On Thu, Jul 19, 2012 at 8:17 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> > Ezequiel,
> >
> > Can you post this patch again, but this time to Linus Torvalds as well?
> >
> > See e.g. http://www.spinics.net/lists/linux-media/msg50407.html how I did that.
> >
> > It would be good to have this fixed in 3.5. I'm afraid that by the time
> > Mauro is back 3.5 will be released and this is a nasty bug.
> >
> 
> Okey, I'll do that. Shouldn't this go to stable also?

Definitely, but it have to be upstreamed first before it can go to stable.

Regards,

	Hans
--
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
Ezequiel Garcia July 24, 2012, 4:50 p.m. UTC | #4
Hey Hans,

On Thu, Jul 19, 2012 at 10:41 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On Thu 19 July 2012 15:32:21 Ezequiel Garcia wrote:
>> On Thu, Jul 19, 2012 at 8:17 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
>> > Ezequiel,
>> >
>> > Can you post this patch again, but this time to Linus Torvalds as well?
>> >
>> > See e.g. http://www.spinics.net/lists/linux-media/msg50407.html how I did that.
>> >
>> > It would be good to have this fixed in 3.5. I'm afraid that by the time
>> > Mauro is back 3.5 will be released and this is a nasty bug.
>> >
>>
>> Okey, I'll do that. Shouldn't this go to stable also?
>
> Definitely, but it have to be upstreamed first before it can go to stable.
>

I was just reading through Documentation/stable_kernel_rules.txt
and I found this:

"Procedure for submitting patches to the -stable tree:

 [snip]
 - To have the patch automatically included in the stable tree, add the tag
     Cc: stable@vger.kernel.org
   in the sign-off area. Once the patch is merged it will be applied to
   the stable tree without anything else needing to be done by the author
   or subsystem maintainer."

So, it was sufficient to Cc this patch to stable and Greg would queued
it automatically when Linus' merges it.

This is also here:
http://www.kroah.com/log/linux/stable-status-01-2012.html

Just wanted you to know this (if you don't already).
Ezequiel.
--
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
diff mbox

Patch

diff --git a/drivers/media/video/cx25821/cx25821-core.c b/drivers/media/video/cx25821/cx25821-core.c
index 83c1aa6..f11f6f0 100644
--- a/drivers/media/video/cx25821/cx25821-core.c
+++ b/drivers/media/video/cx25821/cx25821-core.c
@@ -904,9 +904,6 @@  static int cx25821_dev_setup(struct cx25821_dev *dev)
 	list_add_tail(&dev->devlist, &cx25821_devlist);
 	mutex_unlock(&cx25821_devlist_mutex);
 
-	strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
-	strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
-
 	if (dev->pci->device != 0x8210) {
 		pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
 			__func__, dev->pci->device);
diff --git a/drivers/media/video/cx25821/cx25821.h b/drivers/media/video/cx25821/cx25821.h
index b9aa801..029f293 100644
--- a/drivers/media/video/cx25821/cx25821.h
+++ b/drivers/media/video/cx25821/cx25821.h
@@ -187,7 +187,7 @@  enum port {
 };
 
 struct cx25821_board {
-	char *name;
+	const char *name;
 	enum port porta;
 	enum port portb;
 	enum port portc;