JPMorgan Chase & Co. (JPM) posted a third-quarter profit after a year-earlier loss, while setting aside $1 billion for legal expenses.

Net income printed at $5.6 billion, or $1.36 a share, compared with a loss of $380 million, or 17 cents, a year earlier, just missing expectations.

Earnings were cut by 26 cents a share as the firm set aside funds for legal costs. Mortgage originations were $21.2 billion, down 48% from the prior year and up 26% from the prior quarter.

“Despite challenges, we have continued to deliver strong underlying performance, maintain our fortress balance sheet and liquidity, simplify the business and adapt to regulatory changes,” CEO Jamie Dimon said in the statement.

Revenue in the quarter rose 5.4% to $25.2 billion.

Mortgage banking net income was $439 million, a decrease of $266 million from the prior year, driven by a lower benefit from the provision for credit losses, largely offset by lower noninterest expense.

Net revenue was $2 billion, a decrease of $36 million compared with the prior year. Net interest income was $1 billion, a decrease of $127 million, or 11%, driven by lower warehouse balances, spread compression and lower loan balances due to portfolio runoff. Noninterest revenue was $968 million, an increase of $91 million, driven by a non-recurring gain and higher mortgage fees and related income, partially offset by lower revenue from an exited non-core product.

The provision for credit losses was a benefit of $19 million, compared with a benefit of $1 billion in the prior year. The current quarter reflected a $100 million reduction in the allowance for loan losses, reflecting continued improvement in home prices and delinquencies.

The prior year included a $1.3 billion reduction in the allowance for loan losses. Net charge-offs were $81 million, compared with $206 million in the prior year.

Noninterest expense was $1.3 billion, a decrease of $621 million, or 33%, from the prior year, due to lower expense in production and servicing reflecting lower headcount.

Mortgage Production pretax income was $74 million, a decrease of $16 million from the prior year, reflecting lower revenue and lower benefit from repurchase losses, predominantly offset by lower expense. Mortgage production-related revenue, excluding repurchase losses, was $393 million, a decrease of $191 million from the prior year, primarily on lower volumes. Production expense1 was $381 million, a decrease of $288 million from the prior year, largely due to lower headcount-related expense. Repurchase losses for the current quarter reflected a benefit of $62 million, compared with a benefit of $175 million in the prior year.

Mortgage Servicing pretax income was $138 million, compared with a loss of $406 million in the prior year, reflecting lower expenses and higher MSR risk management income. Mortgage net servicing-related revenue was $639 million, an increase of $7 million from the prior year. MSR risk management income was $76 million, compared with a loss of $180 million in the prior year. Servicing expense was $577 million, a decrease of $281 million from the prior year due to lower expense for foreclosure-related matters and lower headcount-related expense.

Citi (C), the third-largest U.S. bank, and Wells Fargo (WFC), the biggest mortgage lender, report results later today.