Knee wall separating from rafters in garage attic
It's common for nailed roof components to work loose over time due to seasonal movement cycles. If you're sure that there was never any web bracing built into the roof, which the knee-wall studs now replace, the studs are not structural. 

Your solution is probably just fine. I'd have probably used three or four 2-1/2" gold construction screws to save time and expense, but the bolts will do the job. 

One caveat is that you've now transferred the movement somewhere else. You'll either see more pressure into the ceiling joists, or the roof may bulge slightly as things expand and contract. I don't anticipate any problems, though.