The most common bug is double-counting. When computing up[v], you must exclude 's own contribution from down[u]. If you forget, 's subtree gets counted twice in the final answer.
Second common bug: wrong root initialization. The root has no parent, so up[root] = 0. If you skip this or initialize it incorrectly, errors propagate to every node.
Third common bug: confusing node indices. If your tree is -indexed but your arrays are -indexed, off-by-one errors corrupt the results. Pick one convention and stick to it. Print intermediate values (, , ) for a small tree and verify by hand.