The father’s (ex-)wife is a mahram to his sons even if she did not bear him any children
Question

                My father married his cousin (the daughter of his paternal uncle), but she did not bear him any children, so he divorced her. After that he married another woman, and she is my mother. Is it permissible for me to greet my father’s first wife with salaam or not?
Praise be to Allah.
      Your father’s 
      wife is a mahram to you, whether she bore children or not. 

    If he only did the 
    marriage contract with her, and did not consummate the marriage with her, 
    then she is still a mahram to you, because Allah, may He be exalted, said 
    (interpretation of the meaning): “And 
    marry not women whom your fathers married” 
    [an-Nisa’ 4:22]. 
    The wives of fathers and grandfathers become mahrams (to sons and grandsons) 
    as soon as the marriage contract is done. Even if your grandfather or father 
    did not consummate the marriage with her, she is still a mahram to you. If 
    he did consummate the marriage with her and lived with her, then it is more 
    definite that she is a mahram to you, even if she did not bear children. 

    To sum up: the 
    wives of fathers and grandfathers are mahrams (to sons and grandsons) 
    regardless of whether they bore children to your father and grandfathers or 
    not. And Allah knows best.

    End quote 

    Shaykh ‘Abd 
    al-‘Azeez ibn Baaz (may Allah have mercy on him).