Keep in mind that if you plan on replacing the carpet the patch will adhere to the padding making it harder to salvage the pad.
How to replace a section of carpet padding.
Continue around the other edges of the patch in the same manner except in the case where an edge meets a wall as mentioned above.
A line or 2 of glue on the surface of the carpet pad will often be sufficient.
Afterward position something heavy over the area to help set the seam.
Laying the carpet padding is an important part of the carpeting installation process not only because it can make the carpeting feel more comfortable but it will also have an impact on the durability of the carpet.
Older carpet in high traffic areas might be more faded.
Tape neighboring pieces together with 2 to 3 inch masking tape or as directed by the manufacturer.
Press it over the damaged area and turn until you reach the padding then pull out the circular piece and patch as you would a large section.
If you are only replacing a 6x9 foot area with no seams i would likely just replace the carpet and pad if i could find a usable pattern on roll at lowes or home depot or a remnant at a dealer.
In either event be prepared to vacuum up a lot of dirt and possible degraded carpet pad.
Now it is time to install the carpet pad.
Use a staple hammer tacker to fasten the carpet pad against the edge of the tack strip.
If carpet tape is not doing the job you can also use carpet glue to hold the patch in position.
Place the new pad so the waffled side faces up.
Carpet padding has a smooth side and a waffled side.
Install new carpet pad.