linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl: expand the size of the name in fsl_ssi_private struct
@ 2013-05-23  6:26 Nicolin Chen
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolin Chen @ 2013-05-23  6:26 UTC (permalink / raw)
  To: linuxppc-dev, alsa-devel; +Cc: broonie, timur

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(-)

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];
 };
 
-- 
1.7.1

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

* [PATCH] ASoC: fsl: expand the size of the name in fsl_ssi_private struct
@ 2013-05-23  8:51 Nicolin Chen
  2013-05-23 10:21 ` David Laight
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolin Chen @ 2013-05-23  8:51 UTC (permalink / raw)
  To: linuxppc-dev, alsa-devel; +Cc: broonie, timur

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(-)

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];
 };
 
-- 
1.7.1

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

* RE: [PATCH] ASoC: fsl: expand the size of the name in fsl_ssi_private struct
  2013-05-23  8:51 Nicolin Chen
@ 2013-05-23 10:21 ` David Laight
  2013-05-23 11:19   ` Timur Tabi
  0 siblings, 1 reply; 4+ messages in thread
From: David Laight @ 2013-05-23 10:21 UTC (permalink / raw)
  To: Nicolin Chen, linuxppc-dev, alsa-devel; +Cc: broonie, timur

> 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;
>=20
> -	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

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

* Re: [PATCH] ASoC: fsl: expand the size of the name in fsl_ssi_private struct
  2013-05-23 10:21 ` David Laight
@ 2013-05-23 11:19   ` Timur Tabi
  0 siblings, 0 replies; 4+ messages in thread
From: Timur Tabi @ 2013-05-23 11:19 UTC (permalink / raw)
  To: David Laight, Nicolin Chen, linuxppc-dev, alsa-devel; +Cc: broonie

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.

-- 
Timur Tabi

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

end of thread, other threads:[~2013-05-23 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23  6:26 [PATCH] ASoC: fsl: expand the size of the name in fsl_ssi_private struct Nicolin Chen
  -- strict thread matches above, loose matches on Subject: below --
2013-05-23  8:51 Nicolin Chen
2013-05-23 10:21 ` David Laight
2013-05-23 11:19   ` Timur Tabi

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).