It's easy to fix small holes in drywall, such as nail holes, using spackling compound, and holes larger than 5 inches in diameter usually require a drywall patch. That leaves the mid-sized holes, from 1 to 5 inches in diameter, such as the one a doorknob would make. One of the most effective materials you can use to fill them is polyurethane spray foam. It automatically expands to fill the cavity, and when it sets, it's strong enough to prevent another hole from occurring. Closed-cell, low-expansion foam makes the strongest patch and is the easiest type to handle.
Clear debris out of the hole and remove all pieces of drywall or plaster that are clinging to the edges of the hole.
Stuff old newspaper into the hole and arrange it around the bottom so it will support the spray foam. The area behind the hole should remain clear.
Shake an aerosol can of spray foam well and attach the applicator tube that comes with it. Spray foam into the hole, filling it about three-quarters of the way. Let the foam expand to fill the hole -- it should bulge out past the surface of the wall.
Wait for the foam to fully harden, which may take an hour or two. Cut it flush to the surface of the wall, using a utility knife, then shape it so it's slightly concave.
Coat the hardened foam with a layer of drywall joint compound, using a drywall knife. Scrape the joint compound flat with the knife, let it dry overnight, then spread a second coat and scrape it.
Sand the final coat of joint compound flat when it dries, using 120-grit sandpaper. Prime the patch with PVA wall primer, then paint it.