I used to see dreams (and was so much perturbed) that I began to quiver and have temperature, but did not cover myself with a mantle. I met Abu Qatada and made a mention of that to him. He said: I heard Messenger of Allah ﷺ as saying: A good vision comes from Allah and a (bad) dream (hulm) from devil. So when one of you sees a bad dream (hulm) which he does not like, he should spit on his left side thrice and seek refuge with Allah from its evil; then it will not harm him. (Using translation from Muslim 2261a)
كُنْتُ أَرَى الرُّؤْيَا أُعْرَى مِنْهَا غَيْرَ أَنِّي لَا أُزَمَّلُ حَتَّى لَقِيتُ أَبَا قَتَادَةَ فَذَكَرْتُ ذَلِكَ لَهُ فَحَدَّثَنِي عَنْ رَسُولِ اللهِ ﷺ قَالَ الرُّؤْيَا مِنَ اللهِ وَالْحُلْمُ مِنَ الشَّيْطَانِ فَمَنْ رَأَى رُؤْيَا يَكْرَهُهَا فَلَا يُخْبِرْ بِهَا وَلْيَتْفُلْ عَنْ يَسَارِهِ ثَلَاثًا وَلْيَسْتَعِذْ بِاللهِ مِنْ شَرِّهَا؛ فَإِنَّهَا لَا تَضُرُّهُ قَالَ سُفْيَانُ مَرَّةً أُخْرَى فَإِنَّهُ لَنْ يَرَى شَيْئًا يَكْرَهُهُ