Re: [AX.25] Make ax2asc thread-proof

2005-09-06 Thread David S. Miller
From: Ralf Baechle <[EMAIL PROTECTED]>
Date: Tue, 6 Sep 2005 19:12:22 +0100

> Ax2asc was still using a static buffer for all invocations which isn't
> exactly SMP-safe.  Change ax2asc to take an additional result buffer as
> the argument.  Change all callers to provide such a buffer.
> 
> Signed-off-by: Ralf Baechle DL5RB <[EMAIL PROTECTED]>

Applied, thanks a lot Ralf.
-
To unsubscribe from this list: send the line "unsubscribe linux-hams" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[AX.25] Make ax2asc thread-proof

2005-09-06 Thread Ralf Baechle
Ax2asc was still using a static buffer for all invocations which isn't
exactly SMP-safe.  Change ax2asc to take an additional result buffer as
the argument.  Change all callers to provide such a buffer.

Signed-off-by: Ralf Baechle DL5RB <[EMAIL PROTECTED]>

 include/net/ax25.h |2 +-
 net/ax25/af_ax25.c |7 ---
 net/ax25/ax25_addr.c   |3 +--
 net/ax25/ax25_route.c  |7 +--
 net/ax25/ax25_uid.c|4 +++-
 net/netrom/af_netrom.c |7 ---
 net/netrom/nr_route.c  |8 +---
 net/rose/af_rose.c |6 --
 net/rose/rose_route.c  |   14 +-
 net/rose/rose_subr.c   |5 +++--
 10 files changed, 39 insertions(+), 24 deletions(-)

Index: linux-cvs/include/net/ax25.h
===
--- linux-cvs.orig/include/net/ax25.h
+++ linux-cvs/include/net/ax25.h
@@ -278,7 +278,7 @@ extern struct sock *ax25_make_new(struct
 
 /* ax25_addr.c */
 extern ax25_address null_ax25_address;
-extern char *ax2asc(ax25_address *);
+extern char *ax2asc(char *buf, ax25_address *);
 extern ax25_address *asc2ax(char *);
 extern int  ax25cmp(ax25_address *, ax25_address *);
 extern int  ax25digicmp(ax25_digi *, ax25_digi *);
Index: linux-cvs/net/ax25/af_ax25.c
===
--- linux-cvs.orig/net/ax25/af_ax25.c
+++ linux-cvs/net/ax25/af_ax25.c
@@ -1863,6 +1863,7 @@ static void ax25_info_stop(struct seq_fi
 static int ax25_info_show(struct seq_file *seq, void *v)
 {
ax25_cb *ax25 = v;
+   char buf[11];
int k;
 
 
@@ -1874,13 +1875,13 @@ static int ax25_info_show(struct seq_fil
seq_printf(seq, "%8.8lx %s %s%s ",
   (long) ax25,
   ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
-  ax2asc(&ax25->source_addr),
+  ax2asc(buf, &ax25->source_addr),
   ax25->iamdigi? "*":"");
-   seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
+   seq_printf(seq, "%s", ax2asc(buf, &ax25->dest_addr));
 
for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) 
{
seq_printf(seq, ",%s%s",
-  ax2asc(&ax25->digipeat->calls[k]),
+  ax2asc(buf, &ax25->digipeat->calls[k]),
   ax25->digipeat->repeated[k]? "*":"");
}
 
Index: linux-cvs/net/ax25/ax25_addr.c
===
--- linux-cvs.orig/net/ax25/ax25_addr.c
+++ linux-cvs/net/ax25/ax25_addr.c
@@ -36,9 +36,8 @@ ax25_address null_ax25_address = {{0x40,
 /*
  * ax25 -> ascii conversion
  */
-char *ax2asc(ax25_address *a)
+char *ax2asc(char *buf, ax25_address *a)
 {
-   static char buf[11];
char c, *s;
int n;
 
Index: linux-cvs/net/ax25/ax25_route.c
===
--- linux-cvs.orig/net/ax25/ax25_route.c
+++ linux-cvs/net/ax25/ax25_route.c
@@ -284,6 +284,8 @@ static void ax25_rt_seq_stop(struct seq_
 
 static int ax25_rt_seq_show(struct seq_file *seq, void *v)
 {
+   char buf[11];
+
if (v == SEQ_START_TOKEN)
seq_puts(seq, "callsign  dev  mode digipeaters\n");
else {
@@ -294,7 +296,7 @@ static int ax25_rt_seq_show(struct seq_f
if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
callsign = "default";
else
-   callsign = ax2asc(&ax25_rt->callsign);
+   callsign = ax2asc(buf, &ax25_rt->callsign);
 
seq_printf(seq, "%-9s %-4s",
callsign,
@@ -314,7 +316,8 @@ static int ax25_rt_seq_show(struct seq_f
 
if (ax25_rt->digipeat != NULL)
for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
-   seq_printf(seq, " %s", 
ax2asc(&ax25_rt->digipeat->calls[i]));
+   seq_printf(seq, " %s",
+ax2asc(buf, &ax25_rt->digipeat->calls[i]));
 
seq_puts(seq, "\n");
}
Index: linux-cvs/net/ax25/ax25_uid.c
===
--- linux-cvs.orig/net/ax25/ax25_uid.c
+++ linux-cvs/net/ax25/ax25_uid.c
@@ -168,12 +168,14 @@ static void ax25_uid_seq_stop(struct seq
 
 static int ax25_uid_seq_show(struct seq_file *seq, void *v)
 {
+   char buf[11];
+
if (v == SEQ_START_TOKEN)
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
else {
struct ax25_uid_assoc *pt = v;
 
-   seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
+   seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(buf, &pt->call));
}
return 0;
 }
Index: linux-cvs/net/netrom/af_netrom.c
===
--- linux-cvs.orig/net/netrom/af_netrom.c
+++ linux-cvs/net/ne