As a borrower, your lender going bankrupt wouldn't affect you too much. They've already lent you the money after all. If your lender went bankrupt, you wouldn't magically escape your mortgage debt. You would need to keep repaying your loan. If your old lender gets bought up by a new lender, then they will take charge of your mortgage, but your existing loan contract remains in effect.
Learn more about what happens.