Struggling oil and gas companies are maxing out revolving credit lines typically used to cover short-term funding gaps, raising fresh concerns about banks’ exposure to the decline in energy prices.

Midstates Petroleum Co. US:MPOY , Linn Energy LLC US:LINE and SandRidge Energy Inc. US:SDOC in recent weeks drew down the full balance of their revolving credit lines, they said, collectively borrowing more than $1.5 billion to build up cash cushions as the oil slump heads into its second year.

Other producers also are weighing such a move, said bankers and lawyers who advise energy companies. Fully drawing down on a revolving loan can signal a company is building up its cash reserves ahead of a bankruptcy filing or that it is worried lenders may at some point cut off access to credit.

Some banks have started to explore selling revolving loans at a discount to distressed-debt funds, said people familiar with the matter, a sign they don’t expect to get paid in full on the loans, typically seen as safe. Distressed-debt trading desks at Goldman Sachs Group Inc. GS, +0.22% , J.P. Morgan Chase & Co. JPM, +0.64% , Bank of America Corp. BAC, +0.47% and other banks have been quoting prices for some of the loans, though it is unclear if any have traded yet, the people said.

The shift represents another piece of bad news for bank stocks, which have been hammered lately on a number of worries, including the direction of interest rates and how exposed loan portfolios are to the energy sector. The KBW Nasdaq Bank Index is down 23% this year, more than twice as much as the S&P 500.

Revolving loans are typically considered unlikely to lead to losses because they are first in line for repayment in a bankruptcy. They essentially function like credit cards that companies use to cover small or infrequent expenses, such as equipment purchases. Companies typically carry little or no balance on the loans to avoid paying interest on borrowings they don’t immediately need.

An expanded version of this report appears at WSJ.com.