WHEN General Motors was bailed out, the government sank $17 billion of taxpayers’ money into G.M.’s troubled finance arm, GMAC.


Three years on, we’re still waiting for the payback.


While the Treasury Department sold most of its holdings in G.M. last year, it unloaded only a small portion of its stake in GMAC, which is now known as Ally Financial. Taxpayers today own roughly a quarter of G.M., but they still own 74 percent of Ally.


G.M. is making a lot of money (last week, it reported a first-quarter profit of $1.32 billion) but all is not going smoothly at Ally. While the company’s overall numbers are improving, its mortgage unit is in deep trouble.


That unit, Residential Capital, missed a $20 million debt payment in mid-April. Given that it has roughly $300 million in debt payments coming due from now till June, speculation is rife that ResCap will file for bankruptcy.


It’s no shock that an aggressive mortgage originator like ResCap is experiencing hard times. Like others in the industry, it has absorbed enormous losses from bad loans. ResCap also faces a flood of demands to buy back the mortgages it sold to investors and guarantors. These parties contend ResCap breached promises when it sold the loans.


Clearly, ResCap is a burden Ally wants to shed.


Gina Proia, a spokeswoman for Ally Financial, said that maximizing value for shareholders, including taxpayers, was the company’s top priority and that “addressing the risks in the mortgage business is crucial to successfully pursuing strategies that would best position the company.”


A bankruptcy is always messy. But a bankruptcy inside a financial holding company that also owns a bank could be particularly ugly. What might be the unintended consequences? Taxpayers might wonder, for instance, whether a ResCap bankruptcy would hurt Ally’s other operations — and its ability to pay them back.


Granted, the old GMAC has had some success rebuilding itself as Ally Financial. Overseen by Michael A. Carpenter, a former top executive at Citigroup, the company generated net income of $310 million in the first quarter of 2012, versus $146 million in the same period last year.


Ally Bank had $47.2 billion in deposits at the end of the first quarter, with retail deposits up $1.6 billion, or nearly 6 percent. It renewed $15 billion in auto-loan credit facilities that quarter. So far, the company has paid $5.5 billion in stock dividends to the Treasury.


Ally Financial has $11 billion in long-term debt coming due this year. As of March 31, it had $24.5 billion in liquidity.


Such apparent strengths aside, worries over a ResCap bankruptcy prompted Fitch Ratings to warn last month of a possible downgrade in Ally’s senior debt rating, already a junk-bond-grade BB-minus. “These kinds of developments create uncertainties and it is very hard to predict how they play out,” said Christopher Wolfe, a Fitch analyst.


ResCap had $653 million in cash and cash equivalents on its balance sheet at the end of the first quarter, more than enough to pay the debt maturing in coming weeks. Skipping the $20 million debt payment last month, however, sent a clear message that ResCap is in asset-protection mode.


For the moment, depositors and creditors of Ally Financial seem relatively unfazed. That’s surprising, given the deep ties between Ally Financial and ResCap.


As of March 31, for example, Ally had extended $1.4 billion in financing to ResCap. Ally concedes that it might not be paid back if ResCap went bankrupt.


Ally also covered ResCap’s $110 million cash payment in a foreclosure settlement with state attorneys general earlier this year. And Ally’s most recent quarterly report estimated that losses related to ResCap’s litigation and loan repurchase obligations could reach $4 billion more than it has set aside.


“ResCap’s ability to pay for any such losses is very limited,” the filing noted. Disappointed claimants would almost certainly try to move up the corporate ladder to Ally for payment.


Ally could face other costs from a ResCap bankruptcy. For instance, Ally might have to pay more for its financing if investors become spooked or tire of protracted litigation. If yields on Ally’s almost $100 billion in debt, with an average maturity of 3.5 years, rose by one percentage point, that would cost the company $3 billion on a present value basis. This is not an aggressive estimate; after the ResCap bankruptcy talk took hold, spreads on Ally Financial credit default swaps increased by one percentage point.