Petraeus: The leak of an ally’s operation is a blow to the new CIA chief.Getty

So that “CIA coup” in Yemen against another al Qaeda underwear bomber turns out to actually have been a joint Saudi-British intelligence operation — which apparently was prematurely terminated thanks to flapping lips on this side of the Atlantic.

So the leak didn’t just blow our chances to nail the notorious bomb designer behind the plot, Ibrahim al-Asiri, and put the life of the double agent in mortal danger for no reason.

It also seriously damaged Langley’s relationship with its foreign counterparts, who now understand that operational security and the lives of their operatives mean nothing to us (not in an election year, anyway).

Which makes it even more important to find out: Who leaked?

The betting starts with former CIA official John Brennan, the White House’s deputy nationalsecurity adviser for counterterrorism. Shortly after details about the operation leaked to the Associated Press via unnamed “officials,” Brennan took to the airwaves to crow publicly about how the wedgie bomber was “no longer a threat to the American people.”

And the AP admitted it cleared its story with the feds in advance.

The uncharitable immediately saw this naked self-aggrandizement as a blatant attempt by the Obama administration to take political credit for something it had almost nothing to do with.

After all, while the news didn’t break until drone strikes had taken out some al Qaeda in the Arabian Peninsula terrorists, the leak still cut the operation short and, by alerting the enemy to how we did it, made future mole ops much harder.

Again, Brennan & Co. took credit for a success that the CIA apparently had little or nothing to do with. The British domestic security service, MI5, recruited the man somewhere in Europe, then turned him over to MI6 (their CIA equivalent) and to Saudi intel, which ran him jointly.

There’s always a battle between competing intelligence services, with information withheld or leaked according to shifting geopolitical winds. But for the CIA to burn an operation of this magnitude just for media applause isn’t sitting well in London or Riyadh.

The mess is a blow to CIA Director David Petraeus whose reward for winning the Iraq war (and being bruited as a possible presidential candidate) was to be buried alive in suburban Virginia (where he can’t cause any political trouble for Obama).

Petraeus, a consummate pro, is the last man to leak anything. Which brings us back to Brennan, who’s widely disparaged in the national-security community as a shameless self-promoter.

An Arabic-speaking adviser to the 2008 Obama campaign, he was passed over for the top CIA job and instead stashed away on the White House national-security team. It would surprise no one in the intel community were he behind the leak.

Still, you never know. The press crucified Dick Cheney’s deputy, Scooter Libby, for “leaking” the name of CIA analyst Valerie Plame. But it turned out the leaker was Richard Armitage, a deputy to media darling Colin Powell.

But this leak has been too damaging to let slide; both Republican and Democratic Congress members have called for a probe. House Intelligence Committee Chairman Mike Rogers pointed his finger directly at the White House: “Our national security should be exempt from any November, at any time in any year.”

So it’s good news that the nation’s top spook — Director of National Intelligence James Clapper — is going to investigate, right?

Whoops. Clapper’s review of the 16 agencies under his supervision won’t include the White House or its national-security staff. He’s looking at such outfits as the National Reconnaissance Office and the State Department’s Bureau of Intelligence and Research.

Meanwhile, maybe somebody from the FBI, which is also investigating, can stroll over to 1600 Pennsylvania Ave.? Just to be sure.