Commit 0015e551 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

gianfar: Fix possible overrun and simplify interrupt name field creation

Space allocated for int_name_<foo> is insufficient for
maximal device name, expand it.

Code to create int_name_<foo> is obscure, simplify it
by using sprintf.

Found by looking for unnecessary \ line continuations.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dbb6d095
...@@ -968,7 +968,6 @@ static int gfar_probe(struct platform_device *ofdev) ...@@ -968,7 +968,6 @@ static int gfar_probe(struct platform_device *ofdev)
struct gfar_private *priv = NULL; struct gfar_private *priv = NULL;
struct gfar __iomem *regs = NULL; struct gfar __iomem *regs = NULL;
int err = 0, i, grp_idx = 0; int err = 0, i, grp_idx = 0;
int len_devname;
u32 rstat = 0, tstat = 0, rqueue = 0, tqueue = 0; u32 rstat = 0, tstat = 0, rqueue = 0, tqueue = 0;
u32 isrg = 0; u32 isrg = 0;
u32 __iomem *baddr; u32 __iomem *baddr;
...@@ -1169,40 +1168,16 @@ static int gfar_probe(struct platform_device *ofdev) ...@@ -1169,40 +1168,16 @@ static int gfar_probe(struct platform_device *ofdev)
priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
/* fill out IRQ number and name fields */ /* fill out IRQ number and name fields */
len_devname = strlen(dev->name);
for (i = 0; i < priv->num_grps; i++) { for (i = 0; i < priv->num_grps; i++) {
strncpy(&priv->gfargrp[i].int_name_tx[0], dev->name,
len_devname);
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
strncpy(&priv->gfargrp[i].int_name_tx[len_devname], sprintf(priv->gfargrp[i].int_name_tx, "%s%s%c%s",
"_g", sizeof("_g")); dev->name, "_g", '0' + i, "_tx");
priv->gfargrp[i].int_name_tx[ sprintf(priv->gfargrp[i].int_name_rx, "%s%s%c%s",
strlen(priv->gfargrp[i].int_name_tx)] = i+48; dev->name, "_g", '0' + i, "_rx");
strncpy(&priv->gfargrp[i].int_name_tx[strlen( sprintf(priv->gfargrp[i].int_name_er, "%s%s%c%s",
priv->gfargrp[i].int_name_tx)], dev->name, "_g", '0' + i, "_er");
"_tx", sizeof("_tx") + 1);
strncpy(&priv->gfargrp[i].int_name_rx[0], dev->name,
len_devname);
strncpy(&priv->gfargrp[i].int_name_rx[len_devname],
"_g", sizeof("_g"));
priv->gfargrp[i].int_name_rx[
strlen(priv->gfargrp[i].int_name_rx)] = i+48;
strncpy(&priv->gfargrp[i].int_name_rx[strlen(
priv->gfargrp[i].int_name_rx)],
"_rx", sizeof("_rx") + 1);
strncpy(&priv->gfargrp[i].int_name_er[0], dev->name,
len_devname);
strncpy(&priv->gfargrp[i].int_name_er[len_devname],
"_g", sizeof("_g"));
priv->gfargrp[i].int_name_er[strlen(
priv->gfargrp[i].int_name_er)] = i+48;
strncpy(&priv->gfargrp[i].int_name_er[strlen(\
priv->gfargrp[i].int_name_er)],
"_er", sizeof("_er") + 1);
} else } else
priv->gfargrp[i].int_name_tx[len_devname] = '\0'; strcpy(priv->gfargrp[i].int_name_tx, dev->name);
} }
/* Initialize the filer table */ /* Initialize the filer table */
......
...@@ -517,7 +517,7 @@ extern const char gfar_driver_version[]; ...@@ -517,7 +517,7 @@ extern const char gfar_driver_version[];
#define RXFCB_PERR_MASK 0x000c #define RXFCB_PERR_MASK 0x000c
#define RXFCB_PERR_BADL3 0x0008 #define RXFCB_PERR_BADL3 0x0008
#define GFAR_INT_NAME_MAX IFNAMSIZ + 4 #define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */
struct txbd8 struct txbd8
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment