Dobby earned his freedom by getting a sock, thanks to Harry Potter tricking ... However, he freed her from her servitude when he caught her holding a wand in suspicious circumstances.