Yep. Perfectly grammatical. Maybe in older times it was considered wrong, but not anymore. In fact,I am confused about whose.Could it be used for non living thing?
They came to a building whose walls where made of rocks
They came to a building the walls of which were made of rocks <formal> and awkward.
So in fact, whose is considered more natural for most cases