A California appeals court ruled this week inmates can legally possess marijuana in prison – they just can't do anything with it.

The 3rd District Court of Appeal’s 20-page ruling says the state’s voters legalized recreational possession of less than an ounce of cannabis in 2016, with no exception -- even for those behind bars. The decision Tuesday overturned the Sacramento County convictions of five inmates who'd been found with marijuana in their prison cells.

“According to the plain language of...Proposition 64, possession of less than an ounce of cannabis in prison is no longer a felony,” a three-judge panel wrote in the ruling. “Smoking or ingesting cannabis in prison remains a felony.”

Marijuana plants in a grow room using green lights during their night cycle in Gardena, Calif.

Marijuana plants in a grow room using green lights during their night cycle in Gardena, Calif. (AP)

The panel rejected the state’s argument that guards will lose control over prisons if inmates are free to possess small quantities of marijuana, noting possession can still be punished as a rules violation. Such punishments, The Mercury News says, could include having good behavior credits revoked.

POT AND TEENS -- I'M A DOCTOR, AND THIS IS WHAT I TELL MY CHILDREN

Assistant Public Defender David Lynch told the Associated Press “this ruling will prevent inmates from having years added to their sentences for simple possession, reducing overcrowding and saving $50,000-75,000 a year in unnecessary costs.”

But not everyone is pleased with the decision.

"It creates confusion," Dan Olsen, a defense attorney, told FOX40. "If it's illegal to take it in, it's illegal to use it but now it's not illegal to have it. It's sort of like: what's the point of making it not illegal to have it?"

CLICK HERE TO GET THE FOX NEWS APP

Attorney General Xavier Becerra’s office said it is reviewing the ruling and did not say if he will appeal it.

Becerra’s office argued the court’s reading of the law was absurd because it in effect allows controlled substances into prisons. But the court noted that it previously ruled that it’s not illegal for inmates to have properly prescribed medications or medical marijuana behind bars — though it may be against the rules.

The Associated Press contributed to this report.