@@ -131,6 +131,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
131
131
struct uart_port * uport = state -> uart_port ;
132
132
struct tty_port * port = & state -> port ;
133
133
unsigned long page ;
134
+ unsigned long flags = 0 ;
134
135
int retval = 0 ;
135
136
136
137
if (uport -> type == PORT_UNKNOWN )
@@ -145,15 +146,18 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
145
146
* Initialise and allocate the transmit and temporary
146
147
* buffer.
147
148
*/
148
- if (!state -> xmit .buf ) {
149
- /* This is protected by the per port mutex */
150
- page = get_zeroed_page (GFP_KERNEL );
151
- if (!page )
152
- return - ENOMEM ;
149
+ page = get_zeroed_page (GFP_KERNEL );
150
+ if (!page )
151
+ return - ENOMEM ;
153
152
153
+ spin_lock_irqsave (& uport -> lock , flags );
154
+ if (!state -> xmit .buf ) {
154
155
state -> xmit .buf = (unsigned char * ) page ;
155
156
uart_circ_clear (& state -> xmit );
157
+ } else {
158
+ free_page (page );
156
159
}
160
+ spin_unlock_irqrestore (& uport -> lock , flags );
157
161
158
162
retval = uport -> ops -> startup (uport );
159
163
if (retval == 0 ) {
@@ -232,6 +236,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
232
236
{
233
237
struct uart_port * uport = state -> uart_port ;
234
238
struct tty_port * port = & state -> port ;
239
+ unsigned long flags = 0 ;
235
240
236
241
/*
237
242
* Set the TTY IO error marker
@@ -262,10 +267,12 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
262
267
/*
263
268
* Free the transmit buffer page.
264
269
*/
270
+ spin_lock_irqsave (& uport -> lock , flags );
265
271
if (state -> xmit .buf ) {
266
272
free_page ((unsigned long )state -> xmit .buf );
267
273
state -> xmit .buf = NULL ;
268
274
}
275
+ spin_unlock_irqrestore (& uport -> lock , flags );
269
276
}
270
277
271
278
/**
0 commit comments