I think the best summary of the LDS teaching on infallibility, specifically in reference to prophets and revelation, is the following statement from Joseph Smith:
I never told you I was perfect—but there is no error in the revelations which I have taught - (The Words of Joseph Smith, ed. Andrew F. Ehat and Lyndon W. Cook , 369)
In short, nobody who has lived on the earth except Jesus Christ has been or will be infallible; however, those called of God are still capable of receiving and teaching infallible doctrine through revelation.
Since prophets are not infallible, how can we be sure that what they are teaching is infallible doctrine, actual revelation from God? I know of two canonical measuring sticks, there may be more:
Unity of councils. At both general and local levels of leadership in the church, presidents of organizations and congregations are members of a council. For the prophet, he is a member of the 3-person First Presidency and is assisted by the 12-member Quorum of the Twelve Apostles. The decisions of these councils are supposed to be unanimous, according to section 107 of the Doctrine and Covenants, verse 27:
And every decision made by either of these quorums must be by the unanimous voice of the same; that is, every member in each quorum must be agreed to its decisions, in order to make their decisions of the same power or validity one with the other
This process of obtain unanimity is believed to be the working of the Holy Spirit to obtain revelation, in order for divergent viewpoints to be brought together in harmony. From Boyd K. Packer, who was an apostle:
I have, rather, observed a beautiful and remarkable thing—the coming
together, under the directing influence of the Holy Spirit and under
the power of revelation, of divergent views until there is total
harmony and full agreement. Only then is implementation made. That, I
testify, represents the spirit of revelation manifested again and
again in directing this the Lord’s work. - (Ensign, May 1994, 54, 59)
The above quote along with other statements on the process of obtain revelation in a council can be found in this LDS Institute Manual.
This statement from mormonnewsroom.org is also relevant:
Not every statement made by a Church leader, past or present, necessarily constitutes doctrine. A single statement made by a single leader on a single occasion often represents a personal, though well-considered, opinion, but is not meant to be officially binding for the whole Church. With divine inspiration, the First Presidency (the prophet and his two counselors) and the Quorum of the Twelve Apostles (the second-highest governing body of the Church) counsel together to establish doctrine that is consistently proclaimed in official Church publications. This doctrine resides in the four “standard works” of scripture (the Holy Bible, the Book of Mormon, the Doctrine and Covenants and the Pearl of Great Price), official declarations and proclamations, and the Articles of Faith. Isolated statements are often taken out of context, leaving their original meaning distorted.
Personal revelation. The LDS church teaches that each member can and should receive a personal witness through revelation of anything and everything taught in the scriptures and by church leaders and teachers. Doctrine & Covenants 50:21-22 demonstrates this:
21 Therefore, why is it that ye cannot understand and know, that he that receiveth the word by the Spirit of truth receiveth it as it is preached by the Spirit of truth?
22 Wherefore, he that preacheth and he that receiveth, understand one another, and both are edified and rejoice together.
Thus both teaching the word and hearing the word are to be performed by the spirit of God, allowing both the word of truth to be taught by revelation and its truth to be received by revelation.
Similarly, Joseph Smith taught
God hath not revealed anything to Joseph, but what He will make known unto the Twelve [Apostles], and even the least Saint may know all things as fast he is able to bear them. - (Teachings of the Presidents of the Church: Joseph Smith, The Church of Jesus Christ of Latter-day Saints, 2007, 268.)
In summary, no one on the earth except Jesus Christ has been or will be infallible, but through revelation those called of God call still share infallible teachings, and also through revelation those who receive those teachings can come to know of their infallibility.