projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tipc: Provide feedback when log buffer resizing fails
[firefly-linux-kernel-4.4.55.git]
/
net
/
tipc
/
dbg.c
diff --git
a/net/tipc/dbg.c
b/net/tipc/dbg.c
index e809d2a2ce062486f408a923dbdfa2b590ad537f..c6806910598c328a748c3654b6f4b73fd058d5d3 100644
(file)
--- a/
net/tipc/dbg.c
+++ b/
net/tipc/dbg.c
@@
-2,7
+2,7
@@
* net/tipc/dbg.c: TIPC print buffer routines for debugging
*
* Copyright (c) 1996-2006, Ericsson AB
* net/tipc/dbg.c: TIPC print buffer routines for debugging
*
* Copyright (c) 1996-2006, Ericsson AB
- * Copyright (c) 2005-200
6
, Wind River Systems
+ * Copyright (c) 2005-200
7
, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@
-350,43
+350,36
@@
void tipc_dump(struct print_buf *pb, const char *fmt, ...)
}
/**
}
/**
- * tipc_log_stop - free up TIPC log print buffer
+ * tipc_log_resize - change the size of the TIPC log buffer
+ * @log_size: print buffer size to use
*/
*/
-
void tipc_log_stop(void
)
+
int tipc_log_resize(int log_size
)
{
{
+ int res = 0;
+
spin_lock_bh(&print_lock);
if (TIPC_LOG->buf) {
kfree(TIPC_LOG->buf);
TIPC_LOG->buf = NULL;
}
spin_lock_bh(&print_lock);
if (TIPC_LOG->buf) {
kfree(TIPC_LOG->buf);
TIPC_LOG->buf = NULL;
}
- spin_unlock_bh(&print_lock);
-}
-
-/**
- * tipc_log_reinit - (re)initialize TIPC log print buffer
- * @log_size: print buffer size to use
- */
-
-void tipc_log_reinit(int log_size)
-{
- tipc_log_stop();
-
if (log_size) {
if (log_size < TIPC_PB_MIN_SIZE)
log_size = TIPC_PB_MIN_SIZE;
if (log_size) {
if (log_size < TIPC_PB_MIN_SIZE)
log_size = TIPC_PB_MIN_SIZE;
- spin_lock_bh(&print_lock);
tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
log_size);
tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
log_size);
-
spin_unlock_bh(&print_lock)
;
+
res = !TIPC_LOG->buf
;
}
}
+ spin_unlock_bh(&print_lock);
+
+ return res;
}
/**
}
/**
- * tipc_log_resize - reconfigure size of TIPC log buffer
+ * tipc_log_resize
_cmd
- reconfigure size of TIPC log buffer
*/
*/
-struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
+struct sk_buff *tipc_log_resize
_cmd
(const void *req_tlv_area, int req_tlv_space)
{
u32 value;
{
u32 value;
@@
-397,7
+390,9
@@
struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
if (value != delimit(value, 0, 32768))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)");
if (value != delimit(value, 0, 32768))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)");
- tipc_log_reinit(value);
+ if (tipc_log_resize(value))
+ return tipc_cfg_reply_error_string(
+ "unable to create specified log (log size is now 0)");
return tipc_cfg_reply_none();
}
return tipc_cfg_reply_none();
}