The Messenger of Allah ﷺ said, "A true dream is from Allah, and a disturbing dream is from Satan. If any of you sees something he dislikes, let him spit lightly to his left three times, seek refuge with Allah from the accursed Satan three times, and turn over from the side he was lying on."
حدثنا محمد بن رمح حدثنا الليث بن سعد عن يحيى بن سعيد عن أبي سلمة بن عبد الرحمن بن عوف
أن رسول الله ﷺ قال الرؤيا من الله والحلم من الشيطان فإذا رأى أحدكم شيئا يكرهه فليبصق عن يساره ثلاثا وليستعذ بالله من الشيطان الرجيم ثلاثا وليتحول عن جنبه الذي كان عليه
Bukhari recorded it in the chapter on medicine, in the section on blowing while performing ruqya, hadith no. 6984/5747, from the hadith of Yahya bin Saeed, through his chain, and Muslim recorded it in the chapter on dreams, the aforementioned section, vol. 2/2261, from Ibn Ramh, through his chain.