The movie you’re referring to is Harry Potter 2 and the Chamber of Secrets, which is the second film in the Harry Potter series. It was released in 2002 and is based on J.K. Rowling’s second book in the series.
After his first year at Hogwarts School of Witchcraft and Wizardry, Harry Potter returns for his second year, despite warnings from Dobby, a house-elf, who insists that terrible things will happen if Harry goes back to school. Once at Hogwarts, strange events begin to occur. Students and even a cat are found petrified, and rumors swirl about the legendary Chamber of Secrets, a hidden chamber within the school, which is said to house a deadly creature that only the heir of Salazar Slytherin can control.
\
As the mystery unfolds, Harry, along with his friends Ron Weasley and Hermione Granger, discovers that the attacks are linked to the Chamber and that a dark force is at work. They suspect that Tom Riddle, a former student (whose diary Harry finds), might be the key to solving the mystery.
The trio learns that the Chamber of Secrets was supposedly opened before, and only the heir of Slytherin has the ability to unleash the monster inside, a giant serpent called the Basilisk. Eventually, Harry learns that Tom Riddle is actually a younger version of Lord Voldemort, using a magical diary to possess and manipulate Ginny Weasley, Ron’s younger sister, into opening the Chamber.
Harry bravely enters the Chamber of Secrets, confronts the Basilisk, and destroys the diary, thereby vanquishing Riddle’s influence. Ginny is saved, and the attacks on students cease. Dobby, the house-elf, is also freed from servitude when Harry tricks his cruel master, Lucius Malfoy, into giving Dobby a sock.