mirror of https://github.com/schoebel/mars
infra: safeguard dent parent pointer
This commit is contained in:
parent
423ff91956
commit
85b8b1312f
|
@ -1116,11 +1116,13 @@ void bind_to_dent(struct mars_dent *dent, struct say_channel **ch)
|
||||||
// Memoize the channel. This is executed only once for each dent.
|
// Memoize the channel. This is executed only once for each dent.
|
||||||
if (unlikely(!dent->d_say_channel)) {
|
if (unlikely(!dent->d_say_channel)) {
|
||||||
struct mars_dent *test = dent->d_parent;
|
struct mars_dent *test = dent->d_parent;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!test) {
|
if (!test) {
|
||||||
dent->d_say_channel = default_channel;
|
dent->d_say_channel = default_channel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
CHECK_PTR(test, fatal);
|
||||||
if (test->d_use_channel && test->d_path) {
|
if (test->d_use_channel && test->d_path) {
|
||||||
dent->d_say_channel = make_channel(test->d_path,
|
dent->d_say_channel = make_channel(test->d_path,
|
||||||
true);
|
true);
|
||||||
|
@ -1136,6 +1138,7 @@ void bind_to_dent(struct mars_dent *dent, struct say_channel **ch)
|
||||||
if (*ch)
|
if (*ch)
|
||||||
bind_to_channel(*ch, current);
|
bind_to_channel(*ch, current);
|
||||||
}
|
}
|
||||||
|
fatal: ;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(bind_to_dent);
|
EXPORT_SYMBOL_GPL(bind_to_dent);
|
||||||
|
|
||||||
|
@ -1576,20 +1579,20 @@ int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void _reconnect_dent(struct mars_cookie *cookie, struct mars_dent *dent)
|
void _reconnect_dent(struct mars_dent *parent, struct mars_dent *dent)
|
||||||
{
|
{
|
||||||
CHECK_PTR(dent, fatal);
|
CHECK_PTR(dent, fatal);
|
||||||
if (dent->d_parent == cookie->parent)
|
if (dent->d_parent == parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dent->d_parent) {
|
if (dent->d_parent) {
|
||||||
CHECK_PTR(dent->d_parent, fatal);
|
CHECK_PTR(dent->d_parent, fatal);
|
||||||
dent->d_parent->d_child_count--;
|
dent->d_parent->d_child_count--;
|
||||||
}
|
}
|
||||||
dent->d_parent = cookie->parent;
|
dent->d_parent = parent;
|
||||||
if (dent->d_parent) {
|
if (parent) {
|
||||||
CHECK_PTR(cookie->parent, fatal);
|
CHECK_PTR(parent, fatal);
|
||||||
dent->d_parent->d_child_count++;
|
parent->d_child_count++;
|
||||||
}
|
}
|
||||||
fatal: ;
|
fatal: ;
|
||||||
}
|
}
|
||||||
|
@ -1738,7 +1741,7 @@ void _mars_order(struct mars_cookie *cookie, struct mars_dent *dent)
|
||||||
list_add(&dent->dent_hash_link, hash_prev);
|
list_add(&dent->dent_hash_link, hash_prev);
|
||||||
|
|
||||||
found:
|
found:
|
||||||
_reconnect_dent(cookie, dent);
|
_reconnect_dent(cookie->parent, dent);
|
||||||
fatal: ;
|
fatal: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1790,7 +1793,7 @@ void _mars_order_all(struct mars_cookie *cookie)
|
||||||
list_add(&dent->dent_link, &later_anchor);
|
list_add(&dent->dent_link, &later_anchor);
|
||||||
else
|
else
|
||||||
list_add_tail(&dent->dent_link, &later_anchor);
|
list_add_tail(&dent->dent_link, &later_anchor);
|
||||||
_reconnect_dent(cookie, dent);
|
_reconnect_dent(NULL, dent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!cookie->some_ordered) {
|
if (!cookie->some_ordered) {
|
||||||
|
|
Loading…
Reference in New Issue