He masturbated whilst in ihraam
Question

                What does a person have to do if he masturbated on the eighth day of Dhu’l-Hijjah whilst in ihraam?.
Praise be to Allah.Your Hajj is valid according to the more correct of the two scholarly views, but 
    you have to repent to Allaah from that, because masturbation is haraam during Hajj and at other times, as Allaah says (interpretation of the 
    meaning): 
“And those who guard their chastity (i.e. private parts, from illegal sexual 
    acts)
Except from their wives or (the slaves) that their right hands possess, 
     
    for then, they are free from blame;
But whoever seeks beyond that, then those are the transgressors”
[al-Mu’minoon 23:5-7]
And because it causes a great deal of harm as explained by the scholars. 
We ask Allaah to guide us and you and to grant us strength. You also have to offer a sacrifice 
    to be slaughtered in Makkah and its meat distributed to the poor. 
Fataawa al-Shaykh Ibn Baaz, 17/139. 
For the ruling on masturbation please see question no.
    329.