I remember reading somewhere that for the sin of killing Vali from hiding, Vali was reborn as Jara and killed the Krishna avatara.
Gods do not inherit sins due to activities by their avataras. Karma of humans is different from Leela of avatars. Karma causes sins, but Leela does not.
Similar question has been asked by Parīkṣit Mahārāja about the activities of Lord Krishna. The question by Parīkṣit Mahārāja is given below
Parīkṣit Mahārāja said: O brāhmaṇa, the Supreme Personality of Godhead, the Lord of the universe, has descended to this earth along with His plenary portion to destroy irreligion and reestablish religious principles. Indeed, He is the original speaker, follower and guardian of moral laws. How, then, could He have violated them by touching other men’s wives? O faithful upholder of vows, please destroy our doubt by explaining to us what purpose the self-satisfied Lord of the Yadus had in mind when He behaved so contemptibly.
And the response of Śukadeva Gosvāmī clarifies that Leela is different from karma and hence avataras does not carry any sin because of their leela and those (Leelas) activities by avataras should not be imitated by humans, who inherits sins due to their own karma.
Śukadeva Gosvāmī said: The status of powerful controllers is not harmed by any apparently audacious transgression of morality we may see in them, for they are just like fire, which devours everything fed into it and remains unpolluted. One who is not a great controller should never imitate the behavior of ruling personalities, even mentally. If out of foolishness an ordinary person does imitate such behavior, he will simply destroy himself, just as a person who is not Rudra would destroy himself if he tried to drink an ocean of poison. The statements of the Lord’s empowered servants are always true, and the acts they perform are exemplary when consistent with those statements. Therefore one who is intelligent should carry out their instructions. My dear Prabhu, when these great persons who are free from false ego act piously in this world, they have no selfish motives to fulfill, and even when they act in apparent contradiction to the laws of piety, they are not subject to sinful reactions. How, then, could the Lord of all created beings — animals, men and demigods — have any connection with the piety and impiety that affect His subject creatures? Material activities never entangle the devotees of the Supreme Lord, who are fully satisfied by serving the dust of His lotus feet. Nor do material activities entangle those intelligent sages who have freed themselves from the bondage of all fruitive reactions by the power of yoga. So how could there be any question of bondage for the Lord Himself, who assumes His transcendental forms according to His own sweet will?
And one needs to understand that the activities by avataras should be understood properly at all the levels. As told by Śukadeva Gosvāmī, they might appear to be apparent contradiction to the laws of piety to the humans, but they are intended for the benefit of world without any false ego and hence avataras are not subjected to the sinful reactions.