A Utah defense attorney has pleaded guilty to two counts of third-degree felony possession of a controlled substance in a jail, admitting he smuggled heroin and cocaine into the Weber County jail last April.

Forgery and drug paraphernalia charges were dismissed as part of a plea deal.

Tony Miles faces a maximum penalty of up to five years in prison on each count when he is sentenced Dec. 12. Court documents indicate Miles will be participating in drug court.

Prosecutors allege Miles smuggled in drugs to give to inmates — though he did not admit to that in plea agreement documents.

Investigators learned that two prisoners who were caught with drugs had discussed someone nicknamed “Law School” who was bringing a “care package” to the jail, charges state.

Miles did not represent any of the inmates implicated in the case, according to a probable cause statement filed in court, but visited one of them several times in February and March of 2017 and another prior to when Miles was arrested April 7, 2017.

On that day, Miles was at the jail to visit a third inmate, according to charges, and signed in using another name. He then went to the “secure area,” where attorneys meet their clients, according to prosecutors.

There, a sheriff’s deputy told him he was performing random searches, according to charges.

“He became visibly worried,” charges state, “and asked to cancel the visit and exit the facility.”

He then allegedly volunteered that he had a heroin problem and handed the deputy a piece of aluminum foil and a black tube — items that law enforcement say is used to smoke heroin.

When the deputy stepped away to get a glove to collect the items, Miles began fidgeting with his beltline, according to charges. When pressed by the deputy, Miles allegedly gave the law enforcement officer a contact lens case. One side of the case had a “black rock” that looked like heroin, police say, while the other side contained a white powder substance that appeared to be cocaine.

Miles also pleaded guilty to other drug charges in a separate case, relating to drugs that were found in his home.

The Utah State Bar lists Miles as an ”active attorney” in its directory, and no public attorney discipline case has been filed in district court.