It is not legal. The warrant was specifically for one area of the home. If they go and search any other area, they would not be able to use that evidence in court. If they were leaving the house after searching and then as they were leaving noticed something illegal in another room, depending on the state laws, they could then seize that illegal contraband/whatever and use that to prosecute. It just depends on state statute.