The Messenger of Allah ﷺ said, "When one of you goes to his bed, let him take the inner part of his lower garment and dust off his bed with it, and let him mention the name of Allah, for he does not know what may have come onto his bed after he left it. When he wishes to lie down, let him lie on his right side and say, 'Glory be to You, my Lord. By Your name I lay down my side, and by Your name I raise it. If You take my soul, have mercy on it, and if You send it back, protect it with that by which You protect Your righteous servants.'"
و حدثنا إسحق بن موسى الأنصاري حدثنا أنس بن عياض حدثنا عبيد الله حدثني سعيد بن أبي سعيد المقبري عن أبيه
أن رسول الله ﷺ قال إذا أوى أحدكم إلى فراشه فليأخذ داخلة إزاره فلينفض بها فراشه وليسم الله فإنه لا يعلم ما خلفه بعده على فراشه فإذا أراد أن يضطجع فليضطجع على شقه الأيمن وليقل سبحانك اللهم ربي بك وضعت جنبي وبك أرفعه إن أمسكت نفسي فاغفر لها وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين
Both Bukhari and Muslim reported the hadith of Ubaydullah, from Saeed, from his father, from Abu Hurairah, "When one of you goes to his bed, let him shake it out."Bukhari reported it through Zuhayr, from Ubaydullah, and said that Abu Damra and Ismail bin Zakariya followed him in this, and that Yahya and Bishr reported it from Ubaydullah, from Saeed, from Abu Hurairah, and Malik and Ibn Ajlan said likewise.Muslim reported it through Abu Damra and Abdah, from Ubaydullah, from Saeed, from his father, from Abu Hurairah.He said, this hadith has been reported with differing chains going back to Ubaydullah. Zuhayr bin Muawiya, Abu Damra Anas bin Iyad, Ismail bin Zakariya, Abdah bin Sulayman, Abu Badr Shuja bin Walid, Hasan bin Salih, Harim bin Sufyan, Jafar Ahmar, Khalid bin Humayd Rawasi, Yahya bin Saeed Umawi, and Abdullah bin Raja Makki all reported it from Ubaydullah, from Saeed, from his father, from Abu Hurairah.But they were contradicted by Yahya bin Saeed Qattan, Bishr bin Fadl, Mutamir bin Sulayman, Hisham bin Hassan, Hammad bin Zayd, Abdullah bin Mubarak, and Abbad bin Abbad Muhallabi (though there is also disagreement about his version), as well as Abdullah bin Numayr and Uqba bin Khalid Sakuni, who reported it from Ubaydullah, from Saeed, from Abu Hurairah, without mentioning Saeed's father.There is also disagreement regarding Ismail bin Umaya. Yahya bin Saeed reported from him, from Saeed, from Abu Hurairah, while Abdullah bin Raja reported from him, from his father, from Abu Hurairah.
Al-Hafiz said in the introduction to Fath al-Bari, after mentioning Daraqutni's statement, "I say, the answer to a criticism of this kind was already given regarding the second hadith. Bukhari indicated the disagreement about it, both as narrated from Ubaydullah and as narrated from Saeed, so there is no valid objection to him." End of quote.The second hadith referred to is the one in which the Prophet, peace and blessings be upon him and his family, passed by two graves and mentioned the story of the punishment, which will be discussed later, Allah willing.The gist of the answer is that when a narrator is not a mudallis, and it has been established that he heard from both his teacher and his teacher's teacher, and he then narrates the hadith sometimes from one and sometimes from the other, it should be understood that he heard the hadith from both of them.And Allah knows best.