The Messenger of Allah ﷺ said, "When one of you sees a dream he dislikes, let him spit to his left three times, seek refuge with Allah from Satan three times, and turn over from the side he was lying on."
عن رسول الله ﷺ أنه قال: إذا رأى أحدكم الرؤيا يكرهها فليبصق عن يساره ثلاثا، وليستعذ بالله من الشيطان ثلاثا، وليتحول عن جنبه الذي كان عليه.
Muslim narrated it in the Book of Dreams (2262) via Layth, from Abu Zubayr, from Jabir, and he mentioned it. On this topic there are other hadiths mentioned in the Book of Dreams.