Malvolio is and is not in "prison." Somehow (we're never told how), Sir Toby has arranged to have Malvolio, as a madman, bound and confined to a dark room. This treatment, like the padded cell and strait jacket which are still in use today, was supposed to be for the patient's own good, butthen as nowit's hard to tell the difference between therapeutic confinement and prison.
Jack Nicholson, confined in a mad house, from "One Flew Over the Cuckoo's Nest"