Referring to the similar question posted here :
What should I do if I had a nightmare according to the Quran or Hadith?
Islam teaches us some adabs (good behaviour) to do when we get bad dream.
“A good vision (dream) is from Allah and a bad dream is from the
Satan. He who sees something in a dream that he dislikes, should blow
thrice on his left, must seek ...