public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.
@ 2013-05-26  8:50 Chen Gang
  2013-05-26  8:50 ` Chen Gang
  2013-05-27  7:06 ` Sebastian Andrzej Siewior
  0 siblings, 2 replies; 4+ messages in thread
From: Chen Gang @ 2013-05-26  8:50 UTC (permalink / raw)
  To: Thomas Gleixner, H. Peter Anvin
  Cc: mingo@redhat.com, Greg KH, sebastian, zhangyanfei,
	linux-kernel@vger.kernel.org, Linux-Arch


According to the areas which use "%16.16s" within this file, the
'sdev->modalias' may not always be a NUL terminated string.

So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 arch/x86/platform/mrst/mrst.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
index a0a0a43..e2e069c 100644
--- a/arch/x86/platform/mrst/mrst.c
+++ b/arch/x86/platform/mrst/mrst.c
@@ -746,7 +746,7 @@ static void __init intel_scu_spi_device_register(struct spi_board_info *sdev)
 
 	new_dev = kzalloc(sizeof(*sdev), GFP_KERNEL);
 	if (!new_dev) {
-		pr_err("failed to alloc mem for delayed spi dev %s\n",
+		pr_err("failed to alloc mem for delayed spi dev %.16s\n",
 			sdev->modalias);
 		return;
 	}
-- 
1.7.7.6

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

* [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.
  2013-05-26  8:50 [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string Chen Gang
@ 2013-05-26  8:50 ` Chen Gang
  2013-05-27  7:06 ` Sebastian Andrzej Siewior
  1 sibling, 0 replies; 4+ messages in thread
From: Chen Gang @ 2013-05-26  8:50 UTC (permalink / raw)
  To: Thomas Gleixner, H. Peter Anvin
  Cc: mingo@redhat.com, Greg KH, sebastian, zhangyanfei,
	linux-kernel@vger.kernel.org, Linux-Arch


According to the areas which use "%16.16s" within this file, the
'sdev->modalias' may not always be a NUL terminated string.

So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 arch/x86/platform/mrst/mrst.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
index a0a0a43..e2e069c 100644
--- a/arch/x86/platform/mrst/mrst.c
+++ b/arch/x86/platform/mrst/mrst.c
@@ -746,7 +746,7 @@ static void __init intel_scu_spi_device_register(struct spi_board_info *sdev)
 
 	new_dev = kzalloc(sizeof(*sdev), GFP_KERNEL);
 	if (!new_dev) {
-		pr_err("failed to alloc mem for delayed spi dev %s\n",
+		pr_err("failed to alloc mem for delayed spi dev %.16s\n",
 			sdev->modalias);
 		return;
 	}
-- 
1.7.7.6

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

* Re: [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.
  2013-05-26  8:50 [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string Chen Gang
  2013-05-26  8:50 ` Chen Gang
@ 2013-05-27  7:06 ` Sebastian Andrzej Siewior
  2013-05-27  8:16   ` Chen Gang
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-05-27  7:06 UTC (permalink / raw)
  To: Chen Gang
  Cc: Thomas Gleixner, H. Peter Anvin, mingo@redhat.com, Greg KH,
	zhangyanfei, linux-kernel@vger.kernel.org, Linux-Arch

On Sun, May 26, 2013 at 04:50:22PM +0800, Chen Gang wrote:
> 
> According to the areas which use "%16.16s" within this file, the
> 'sdev->modalias' may not always be a NUL terminated string.
> 
> So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

No. spi_match_id() expects a NULL terminated string and I would be suprised if
it would be otherwise. Therefore moorsetown or this files has to learn to NULL
terminate its strings.

> Signed-off-by: Chen Gang <gang.chen@asianux.com>

Sebastian

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

* Re: [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.
  2013-05-27  7:06 ` Sebastian Andrzej Siewior
@ 2013-05-27  8:16   ` Chen Gang
  0 siblings, 0 replies; 4+ messages in thread
From: Chen Gang @ 2013-05-27  8:16 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Thomas Gleixner, H. Peter Anvin, mingo@redhat.com, Greg KH,
	zhangyanfei, linux-kernel@vger.kernel.org, Linux-Arch, Alan Cox

On 05/27/2013 03:06 PM, Sebastian Andrzej Siewior wrote:
> On Sun, May 26, 2013 at 04:50:22PM +0800, Chen Gang wrote:
>> > 
>> > According to the areas which use "%16.16s" within this file, the
>> > 'sdev->modalias' may not always be a NUL terminated string.
>> > 
>> > So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.
> No. spi_match_id() expects a NULL terminated string and I would be suprised if
> it would be otherwise. Therefore moorsetown or this files has to learn to NULL
> terminate its strings.
> 

In spi_match_id(), it is 'spi_device', not 'spi_board_info'. ;-)

But all together, it is my fault, the original implementation has no
issue: "I treated SFI_NAME_LEN as SPI_NAME_LEN when strncpy()".

BTW: 'pentry->name' in sfi_parse_devs() may not always be a NUL
terminated string, could you give a check, too ?  ;-)


Thanks.
-- 
Chen Gang

Asianux Corporation

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

end of thread, other threads:[~2013-05-27  8:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-26  8:50 [PATCH] arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string Chen Gang
2013-05-26  8:50 ` Chen Gang
2013-05-27  7:06 ` Sebastian Andrzej Siewior
2013-05-27  8:16   ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox