All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ʻalayhi wa sallam, is His slave and Messenger.
This meaning was reported in the following hadith:
The Prophet, sallallahu ʻalayhi wa sallam, said, “Whoever reads the Quran, learns it, and acts in accordance with it, on the Day of Resurrection, his parents will be given a crown to wear whose light will be like the light of the sun, and his parents will be given garments which far surpass everything that is found in this world. They will say, ‘Why have we been given this to wear?’ It will be said, ‘Because your child learned the Quran.’” [Al-Haakim; Al-Albaani: authentic, in Saheeh At-Targheeb]
The apparent indication of the hadith is that the parents earn this reward when their child memorizes the Quran regardless of whether they were the reason for it or not. This is one of the means through which Allah, the Exalted, causes some of His slaves to earn benefit. Like similar religious texts, this hadith is indicative of a promise; it does not necessarily mean that a specific person shall definitely earn this reward, as this is contingent on the fulfillment of a set of conditions and the absence of certain impediments. So it is not necessarily true that any parents whose child has memorized the Quran shall not be punished if they committed what entails punishment. Rather, it is hoped that they will earn this reward and that Allah will pardon them by the blessing of their child's memorization of the Quran.
Allah knows best.