diff options
author | Joe Perches <joe@perches.com> | 2012-03-25 03:10:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-25 13:27:48 -0400 |
commit | 0015e551edb1d28191567d8a7d1ce5edda404ced (patch) | |
tree | a0f8c8e5b7a81bb8aa00007a47454a7cfc62bf9e /drivers/net/ethernet/freescale | |
parent | dbb6d0956877b99e78b8e0dc0e4e56d9e936b5ab (diff) |
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: Joe Perches <joe@perches.com>
Tested-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale')
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 39 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.h | 2 |
2 files changed, 8 insertions, 33 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index d9428f0e738a..e7bed5303997 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -968,7 +968,6 @@ static int gfar_probe(struct platform_device *ofdev) | |||
968 | struct gfar_private *priv = NULL; | 968 | struct gfar_private *priv = NULL; |
969 | struct gfar __iomem *regs = NULL; | 969 | struct gfar __iomem *regs = NULL; |
970 | int err = 0, i, grp_idx = 0; | 970 | int err = 0, i, grp_idx = 0; |
971 | int len_devname; | ||
972 | u32 rstat = 0, tstat = 0, rqueue = 0, tqueue = 0; | 971 | u32 rstat = 0, tstat = 0, rqueue = 0, tqueue = 0; |
973 | u32 isrg = 0; | 972 | u32 isrg = 0; |
974 | u32 __iomem *baddr; | 973 | u32 __iomem *baddr; |
@@ -1169,40 +1168,16 @@ static int gfar_probe(struct platform_device *ofdev) | |||
1169 | priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); | 1168 | priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET); |
1170 | 1169 | ||
1171 | /* fill out IRQ number and name fields */ | 1170 | /* fill out IRQ number and name fields */ |
1172 | len_devname = strlen(dev->name); | ||
1173 | for (i = 0; i < priv->num_grps; i++) { | 1171 | for (i = 0; i < priv->num_grps; i++) { |
1174 | strncpy(&priv->gfargrp[i].int_name_tx[0], dev->name, | ||
1175 | len_devname); | ||
1176 | if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { | 1172 | if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { |
1177 | strncpy(&priv->gfargrp[i].int_name_tx[len_devname], | 1173 | sprintf(priv->gfargrp[i].int_name_tx, "%s%s%c%s", |
1178 | "_g", sizeof("_g")); | 1174 | dev->name, "_g", '0' + i, "_tx"); |
1179 | priv->gfargrp[i].int_name_tx[ | 1175 | sprintf(priv->gfargrp[i].int_name_rx, "%s%s%c%s", |
1180 | strlen(priv->gfargrp[i].int_name_tx)] = i+48; | 1176 | dev->name, "_g", '0' + i, "_rx"); |
1181 | strncpy(&priv->gfargrp[i].int_name_tx[strlen( | 1177 | sprintf(priv->gfargrp[i].int_name_er, "%s%s%c%s", |
1182 | priv->gfargrp[i].int_name_tx)], | 1178 | dev->name, "_g", '0' + i, "_er"); |
1183 | "_tx", sizeof("_tx") + 1); | ||
1184 | |||
1185 | strncpy(&priv->gfargrp[i].int_name_rx[0], dev->name, | ||
1186 | len_devname); | ||
1187 | strncpy(&priv->gfargrp[i].int_name_rx[len_devname], | ||
1188 | "_g", sizeof("_g")); | ||
1189 | priv->gfargrp[i].int_name_rx[ | ||
1190 | strlen(priv->gfargrp[i].int_name_rx)] = i+48; | ||
1191 | strncpy(&priv->gfargrp[i].int_name_rx[strlen( | ||
1192 | priv->gfargrp[i].int_name_rx)], | ||
1193 | "_rx", sizeof("_rx") + 1); | ||
1194 | |||
1195 | strncpy(&priv->gfargrp[i].int_name_er[0], dev->name, | ||
1196 | len_devname); | ||
1197 | strncpy(&priv->gfargrp[i].int_name_er[len_devname], | ||
1198 | "_g", sizeof("_g")); | ||
1199 | priv->gfargrp[i].int_name_er[strlen( | ||
1200 | priv->gfargrp[i].int_name_er)] = i+48; | ||
1201 | strncpy(&priv->gfargrp[i].int_name_er[strlen(\ | ||
1202 | priv->gfargrp[i].int_name_er)], | ||
1203 | "_er", sizeof("_er") + 1); | ||
1204 | } else | 1179 | } else |
1205 | priv->gfargrp[i].int_name_tx[len_devname] = '\0'; | 1180 | strcpy(priv->gfargrp[i].int_name_tx, dev->name); |
1206 | } | 1181 | } |
1207 | 1182 | ||
1208 | /* Initialize the filer table */ | 1183 | /* Initialize the filer table */ |
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index fc2488adca36..4c9f8d487dbb 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h | |||
@@ -517,7 +517,7 @@ extern const char gfar_driver_version[]; | |||
517 | #define RXFCB_PERR_MASK 0x000c | 517 | #define RXFCB_PERR_MASK 0x000c |
518 | #define RXFCB_PERR_BADL3 0x0008 | 518 | #define RXFCB_PERR_BADL3 0x0008 |
519 | 519 | ||
520 | #define GFAR_INT_NAME_MAX IFNAMSIZ + 4 | 520 | #define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */ |
521 | 521 | ||
522 | struct txbd8 | 522 | struct txbd8 |
523 | { | 523 | { |