It is narrated from Ibn Umar (may Allah be pleased with them both) that Umar (may Allah be pleased with him) became the owner of one hundred shares from Khaybar which he had purchased, and he came to the Messenger of Allah (peace and blessings be upon him) and said: "O Messenger of Allah! I have acquired such wealth that I have never acquired better wealth than this before, and I intend to seek nearness to Allah through it." Upon this, the Prophet (peace and blessings be upon him) said: "Keep the ownership of the garden, and dedicate its fruits in the way of Allah."
Hadith Referenceمسند الإمام الشافعي / كتاب الوقف والعمرى والرقبى / 1061
Hadith Takhrijأخرجه ابن ماجة، الصدقات، باب من وقف (2397) والنسائي، الأحباس، باب حبس المشاع (3633، 3634، 3635) وصححه ابن خزيمة (2486) وابن حبان۔