Praise be to Allah.
It was reported that the Prophet (peace and blessings of Allaah be upon him) said: “The deceased is punished by the weeping of his family for him.”(Narrated by al-Bukhaari, 1286). This was explained as meaning, when a person had told his family to do that, as was done during the Jaahiliyyah. And it was said that it meant, if their custom was to weep and wail and he did not warn them. And it was said that it meant, he would feel hurt and saddened because they were doing something that would not help them at all; it does not refer to the punishment of the Fire. But simply mentioning the person, feeling grief and saying “Innaa Lillaahi wa innaa ilayhi raaji’oon (to Allaah we belong and unto Him is our return)” – these actions are not included in this prohibition, because these feelings are something that overwhelm a person, and he cannot help thinking of the deceased, mentioning him, grieving for him and feeling sorrow because of his loss. If he mentions him, says “Innaa Lillaahi wa innaa ilayhi raaji’oon,” and prays to his Lord for patience and consolation and to be compensated with something better, then Allaah will reward him for bearing this loss.