You'll have to check with your bank, but they should have something in place for this. The bank need to give their agreement to sell the current house, and part of that sets out an agreement for repayment of the shortfall amount.
There is generally a condition that the new mortgage must be drawn down within 1 year of the old one being repaid, especially if you have a tracker.
It's very important that you pay the agreed shortfall repayments as missing them could lead to a refusal to issue new mortgage when the time comes.