tipc: Fix recursive spinlock invocation in print buffer code
This patch fixes two routines that allow the global print buffer spinlock to be taken recursively. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
fb98ec71c7
commit
93758c3da1
|
@ -179,8 +179,10 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb_to->size < pb_from->size) {
|
if (pb_to->size < pb_from->size) {
|
||||||
tipc_printbuf_reset(pb_to);
|
strcpy(pb_to->buf, "*** PRINT BUFFER MOVE ERROR ***");
|
||||||
tipc_printf(pb_to, "*** PRINT BUFFER MOVE ERROR ***");
|
pb_to->buf[pb_to->size - 1] = ~0;
|
||||||
|
pb_to->crs = strchr(pb_to->buf, 0);
|
||||||
|
pb_to->next = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,27 +407,32 @@ struct sk_buff *tipc_log_dump(void)
|
||||||
struct sk_buff *reply;
|
struct sk_buff *reply;
|
||||||
|
|
||||||
spin_lock_bh(&print_lock);
|
spin_lock_bh(&print_lock);
|
||||||
if (!TIPC_LOG->buf)
|
if (!TIPC_LOG->buf) {
|
||||||
|
spin_unlock_bh(&print_lock);
|
||||||
reply = tipc_cfg_reply_ultra_string("log not activated\n");
|
reply = tipc_cfg_reply_ultra_string("log not activated\n");
|
||||||
else if (tipc_printbuf_empty(TIPC_LOG))
|
} else if (tipc_printbuf_empty(TIPC_LOG)) {
|
||||||
|
spin_unlock_bh(&print_lock);
|
||||||
reply = tipc_cfg_reply_ultra_string("log is empty\n");
|
reply = tipc_cfg_reply_ultra_string("log is empty\n");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
struct tlv_desc *rep_tlv;
|
struct tlv_desc *rep_tlv;
|
||||||
struct print_buf pb;
|
struct print_buf pb;
|
||||||
int str_len;
|
int str_len;
|
||||||
|
|
||||||
str_len = min(TIPC_LOG->size, 32768u);
|
str_len = min(TIPC_LOG->size, 32768u);
|
||||||
|
spin_unlock_bh(&print_lock);
|
||||||
reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len));
|
reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len));
|
||||||
if (reply) {
|
if (reply) {
|
||||||
rep_tlv = (struct tlv_desc *)reply->data;
|
rep_tlv = (struct tlv_desc *)reply->data;
|
||||||
tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
|
tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
|
||||||
|
spin_lock_bh(&print_lock);
|
||||||
tipc_printbuf_move(&pb, TIPC_LOG);
|
tipc_printbuf_move(&pb, TIPC_LOG);
|
||||||
|
spin_unlock_bh(&print_lock);
|
||||||
str_len = strlen(TLV_DATA(rep_tlv)) + 1;
|
str_len = strlen(TLV_DATA(rep_tlv)) + 1;
|
||||||
skb_put(reply, TLV_SPACE(str_len));
|
skb_put(reply, TLV_SPACE(str_len));
|
||||||
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
|
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&print_lock);
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue