LATIMER, Justice. This is a habeas corpus proceeding. The petitioner, Julius Brown, a resident of New York City, was convicted in magistrate's court in Fayette County of a violation of the Narcotic Act. Pursuant to KRS 218.250 he was sentenced to twelve months in the Fayette County jail, and then probated to the United States Public Health Service Hospital or until discharged by the hospital's medical officers as no longer addicted to drugs.
Apparently petitioner had formerly entered the hospital about the first of March, 1951 as a voluntary patient, where he remained for approximately fifteen days, when, it is claimed, he requested to be released, believing himself to be cured of the drug habit. He then returned to his home in New York City. In July, 1951, he returned to the hospital and asked that he be permitted voluntarily to reenter. The officials of the hospital informed him that it would be necessary to contact the United States narcotic agents at Lexington. This was done. The narcotic agents then came to the hospital and immediately took petitioner before Magistrate Jackson in Lexington where petitioner stated he was a narcotic addict, resulting in the sentence and probation above. He was then returned to the hospital where he remained until July 27 when he decided to leave against the advice of its medical officers, thereby violating the probation. He was then taken before the magistrate, who revoked his probation and committed him to jail for the remainder of the twelve months sentence. He filed this petition and a hearing was had before Judge Joseph J. Bradley, who ruled that the petitioner was in lawful custody of the Fayette County jailer by reason of the judgment rendered in the magistrate's court. From that ruling this appeal is prosecuted.
A number of propositions are called to our attention, chief among which is that in misdemeanor cases, where maximum and minimum penalties are prescribed and the defendant waives the right to a trial by jury and pleads guilty, the judge is obliged to inflict the minimum penalty. A long line of cases support this contention. The Statute KRS 431.130, and Criminal Code of Practice, § 257, prescribe that a jury shall fix the degree of punishment. Were this an appeal because of error of the court in sentencing to more than the minimum penalty, the cause would have to be reversed.
It is fundamental that a proceeding invoking the aid of a writ of habeas corpus to secure the discharge of one restrained of his liberty by virtue of a judgment is a collateral attack upon the validity of that judgment, and consequently, must be governed by the general rules applicable to collateral attacks upon judgments. The writ will lie where the judgment so attacked is void and not where it is merely erroneous. Where the court had jurisdiction of the person and subject-matter of prosecution, habeas corpus will not lie for the release of a prisoner because of errors. The general rule obtains, therefore, that a judgment of a court of competent jurisdiction is effective until it is reversed. We have held in an imposing line of cases that no error of law committed by trial court can be reversed on habeas corpus, since such proceeding is a collateral attack on a judgment under which the prisoner is confined and may be sustained only where the judgment is void. Department of Public Welfare v. Polsgrove, County Judge, 250 Ky. 517, 63 S.W.2d 603; Smith v. Buchanan, 291 Ky. 44, 163 S.W.2d 5, 145 A.L.R. 813; Hoskins v. Buchanan, 311 Ky. 246, 223 S.W.2d 904; Sexton v. Buchanan, Warden, 292 Ky. 716, 168 S.W.2d 19; Anderson v. Buchanan, 292 Ky. 810, 168 S.W.2d 48.
The testimony of the petitioner shows that he understood what was taking place, and why. Had he properly appealed from the judgment fixing the maximum sentence of twelve months, without the intervention of a jury, this error could have been corrected. We cannot, through a proceeding of this kind, say that there is error in regard to the punishment imposed by a court, which had jurisdiction of both the party and the offense.
We deem it unnecessary to discuss other points raised by petitioner.
The judgment is affirmed.