#undef _GNU_SOURCE #include #include #include /* * The tools so far have been using the strerror_r() GNU variant, that returns * a string, be it the buffer passed or something else. * * But that, besides being tricky in cases where we expect that the function * using strerror_r() returns the error formatted in a provided buffer (we have * to check if it returned something else and copy that instead), breaks the * build on systems not using glibc, like Alpine Linux, where musl libc is * used. * * So, introduce yet another wrapper, str_error_r(), that has the GNU * interface, but uses the portable XSI variant of strerror_r(), so that users * rest asured that the provided buffer is used and it is what is returned. */ char *str_error_r(int errnum, char *buf, size_t buflen) { int err = strerror_r(errnum, buf, buflen); if (err) snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); return buf; } /> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-06 14:12:51 +0100
committerDavid Sterba <dsterba@suse.com>2017-01-09 11:24:50 +0100
commitac0c7cf8be00f269f82964cf7b144ca3edc5dbc4 (patch)
treeec90457b5fe8979eeb3f3d63cc6131ed53b1f735
parent2939e1a86f758b55cdba73e29397dd3d94df13bc (diff)
btrfs: fix crash when tracepoint arguments are freed by wq callbacks
Enabling btrfs tracepoints leads to instant crash, as reported. The wq callbacks could free the memory and the tracepoints started to dereference the members to get to fs_info. The proposed fix https://marc.info/?l=linux-btrfs&m=148172436722606&w=2 removed the tracepoints but we could preserve them by passing only the required data in a safe way. Fixes: bc074524e123 ("btrfs: prefix fsid to all trace events") CC: stable@vger.kernel.org # 4.8+ Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>