I assume you have a lease agreement with your landlord. That agreement is between you and him, and the not his bank. His agreement to pay his mortgage is between him and his bank. Until the foreclosure is actually COMPLETE, you are under obligation to pay your monthly rent to your landlord.
Once the foreclosure is complete, your lease is considered terminated. The landlord is also responsible to return your security deposit to you at the termination, but this may be a difficulty, and could lead to a Small Claims court claim.