I would guess there is a very good chance he is getting railroaded but he also acts like a giant POS and maybe this is how he finally learns his manners.
I feel conflicted when this happens. It's not what the CJS is for, but it's not exactly a bad result and I'd rather have this than harassing non-violent drug offenders.