Sayyidah Aishah Siddiqah (may Allah be pleased with her) transmits this as a marfu' report: the Prophet (peace and blessings be upon him) said: "Doing good is fitting only toward a person of noble lineage or of religion, just as training is fitting only for a horse of good breed."
Al-Bazzar recorded it; its chain contains a narrator, Ubayd bin al-Qasim, who is a kadhdhab (liar).