The Prophet ﷺ said, "When one of you retires to his bed, let him dust off his bed with the inner edge of his lower garment, for he does not know what may have come upon it after he left it. Then let him say, 'In Your name, my Lord, I lay down my side, and by You I raise it. If You take my soul, then have mercy on it, and if You send it back, then protect it with that by which You protect Your righteous servants.'"Abu Damrah and Ismail bin Zakariya followed this narration from Ubaydullah. Yahya and Bishr narrated it from Ubaydullah, from Saeed, from Abu Hurairah, from the Prophet ﷺ. Malik and Ibn Ajlan also narrated it from Saeed, from Abu Hurairah, from the Prophet ﷺ.
باب حدثنا أحمد بن يونس حدثنا زهير حدثنا عبيد الله بن عمر حدثني سعيد بن أبي سعيد المقبري عن أبيه
قال النبي ﷺ إذا أوى أحدكم إلى فراشه فلينفض فراشه بداخلة إزاره فإنه لا يدري ما خلفه عليه ثم يقول باسمك رب وضعت جنبي وبك أرفعه إن أمسكت نفسي فارحمها وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين تابعه أبو ضمرة وإسماعيل بن زكرياء عن عبيد الله وقال يحيى وبشر عن عبيد الله عن سعيد عن أبي هريرة عن النبي ﷺ ورواه مالك وابن عجلان عن سعيد عن أبي هريرة عن النبي ﷺ
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.