Sayyiduna Ibn Umar (may Allah be pleased with them both) said that the Messenger of Allah (peace and blessings be upon him) said: "Do not make the mosques into passageways, except (for coming) for remembrance (of Allah) or prayer."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 13162