First, fix the leak causing the damage. Then, clean the stained area with a bleach solution to remove mold or mildew. Apply a stain-blocking primer before repainting to stop the stain from showing through.