diff mbox

ASoC: fsl: expand the size of the name in fsl_ssi_private struct

Message ID 1369299072-25147-1-git-send-email-b42378@freescale.com (mailing list archive)
State Rejected
Headers show

Commit Message

Nicolin Chen May 23, 2013, 8:51 a.m. UTC
strcpy(ssi_private->name, p) in probe() sets "name" by "p", gotten from dts,
while the length of "p", if the devicetree node name of SSI is commonly set,
would always be larger than 1 char size, so need a larger size for "name".

Signed-off-by: Nicolin Chen <b42378@freescale.com>
---
 sound/soc/fsl/fsl_ssi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

David Laight May 23, 2013, 10:21 a.m. UTC | #1
> strcpy(ssi_private->name, p) in probe() sets "name" by "p", gotten from dts,
> while the length of "p", if the devicetree node name of SSI is commonly set,
> would always be larger than 1 char size, so need a larger size for "name".

Are you sure this isn't allowed for when the structure is allocated?
Otherwise you also need to use strlcpy() as well.

> @@ -152,5 +152,5 @@ struct fsl_ssi_private {
>  	} stats;
> 
> -	char name[1];
> +	char name[32];
>  };

This looks like what c99 allows 'char name[0]' be used for.
But ensure the \0 is allowed for before changing to 1 to 0.

	David
Timur Tabi May 23, 2013, 11:19 a.m. UTC | #2
David Laight wrote:
>> strcpy(ssi_private->name, p) in probe() sets "name" by "p", gotten from dts,
>> >while the length of "p", if the devicetree node name of SSI is commonly set,
>> >would always be larger than 1 char size, so need a larger size for "name".
> Are you sure this isn't allowed for when the structure is allocated?
> Otherwise you also need to use strlcpy() as well.

Yes, this is already handled properly:

p = strrchr(np->full_name, '/') + 1;
ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p),
                       GFP_KERNEL);

Nicolin's patch is wrong.  Do not apply it.
diff mbox

Patch

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 2f2d837..b6a5f94 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -152,5 +152,5 @@  struct fsl_ssi_private {
 	} stats;
 
-	char name[1];
+	char name[32];
 };