Skip to contentSkip to conversation

i2c: sun6-p2wi: fix call to snprintf

PATCH New Boris BREZILLON 2 participants 3 messages Jun 13, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CAGXu5jLi5NXNsbUAn=XndDb2JSTxiVhMWbiMxtDsUOqZZhxf2A@mail.gmail.com

#1 lore raw

PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf

Fixes possible issue in case pdev name contains formatting characters.

---
 drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-sun6i-p2wi.c +2 -1
index 5d2d678..63d1b2d 100644
@@ -237,7 +237,8 @@ static int p2wi_probe(struct platform_device *pdev)
 	if (IS_ERR(p2wi->regs))
 		return PTR_ERR(p2wi->regs);
 
-	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
+	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
+		 pdev->name);
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "failed to retrieve irq: %d\n", irq);
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf

drivers/i2c/busses/i2c-sun6i-p2wi.c static int p2wi_probe(struct platform_device *pdev) · line 241

Quoted 3 lines · Boris BREZILLON
drivers/i2c/busses/i2c-sun6i-p2wi.c +2 -1
-	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
+	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
+		 pdev->name);

Isn't this just a complicated way to express:

	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));

?

Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
#3 lore raw

PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf

Quoted 9 lines · Russell King - ARM Linux

drivers/i2c/busses/i2c-sun6i-p2wi.c static int p2wi_probe(struct platform_device *pdev) · line 241

Quoted 3 lines · Boris BREZILLON
drivers/i2c/busses/i2c-sun6i-p2wi.c +2 -1
-	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
+	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
+		 pdev->name);

Isn't this just a complicated way to express:

	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));

?

Yes it is. I'll make use of strlcpy instead.

Thanks,

Boris

Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com