Hadithcore
Hadith #2109570

Narrated Ibn 'Umar (RA):

'Umar (RA) forbade the sale of the slave-women who have given birth to children (of their owners). He said, "She is not to be sold, bestowed as a gift or inherited. He (the owner) enjoys her as long as he lives and when he dies, she becomes free." [Reported by Malik an al-Baihaqi. He said: Some of the narrators have attributed it to the Prophet (ﷺ) mistakenly].

وَعَنِ اِبْنِ عُمَرَ ‏-رَضِيَ اَللَّهُ عَنْهُمَا‏- قَالَ: { نَهَى عُمَرُ عَنْ بَيْعِ أُمَّهَاتِ اَلْأَوْلَادِ فَقَالَ: لَا تُبَاعُ, وَلَا تُوهَبُ, وَلَا تُورَثُ, لِيَسْتَمْتِعْ بِهَا مَا بَدَا لَهُ، فَإِذَا مَاتَ فَهِيَ حُرَّةٌ } رَوَاهُ مَالِكٌ, وَالْبَيْهَقِيُّ, وَقَالَ: رَفَعَهُ بَعْضُ اَلرُّوَاةِ, فَوَهِمَ [1]‏ .‏

References2 variants
Sunnah.com reference
Book 7, Hadith 13
Arabic/English book reference
Book 7, Hadith 794