A very common material in modern home construction isto repair water damaged drywall Drywall is basically crushed gypsum applied as a glue between two or more sheets of cardboard. The result is a modestly weighty, fairly waterproof, and absolutely level broad surface to be applied between beams of wood. When the skeleton of a house is erected, drywall fills in the gaps to give homes their perfectly squared look. Drywall is used to cut down on the consumption of wood, and because it insulates while also being less attractive to pests than wood. Because gypsum is a mineral, it does not rot.
For all of its virtues, gypsum is not as sturdy as wood, and can be broken. In particular, gypsum has no flexibility, and when a wide section is compressed, it easily breaks. Once installed, it does not break easily, because the wood skeleton absorbs the stress if, say, you trip and fell against it. On the other hand, if you are hammering a nail and the hammer slips, it is not too difficult to punch a hole in the drywall. The damage is unsightly, but it does not undermine the structural integrity of the house; sheet gypsum has little structural strength and is just there to provide a wall. On the other hand, that hole may become an entry point for ants or cockroaches living in the space between your wall.
If the drywall has been damaged by a leak from a pipe, then you are still stuck with the same problem. Assess the size of the damage, then correct as necessary. If it is just a hole, then scoop out the damaged material with a knife and apply wall plaster to the hole. Once the material has dried, sandpaper it level with the wall and repaint. If the project is much larger, then it becomes necessary to cut out the damaged area. For a small area, you can probably do it yourself; for a large section damage, get a professional.
While repairing water damaged drywall, the key is to cut away the damaged material. It is not necessary to replace entire sheets of drywall; this is probably impossible becuase of the carpet, and this is only necessary with large projects. At any rate, remove the damage with a boxcutter or fine saw, making sure not to damage the beams of wood. Cut a new section of drywall to the shape of the hole, then make it a little bit smaller so it will fit. Screw the new piece into the beams of wood, and fill in the edges with putty.