Can a student with a weak or average undergraduate math GPA realistically become a professor? I just finished my second year of undergraduate studies as a double major in computer engineering and mathematics at the University of Iowa. Although I came in believing that I wanted to become a software engineer, I've become more interested in pursuing math as I learn more about it. 

To be completely honest, I was somewhat directionless and unmotivated when I started my studies and I didn't quite achieve the grades that I wanted. I finished my first year with a GPA somewhere around a 3.45 on a 4.0 scale. However, I managed to put forth a lot more effort into my coursework this year, pulling my overall GPA up to a 3.60 (and achieving a 3.8 this last semester). 

The problem is that my mathematics GPA is still somewhere around a 3.48. The graduate school at my university requires a 3.4 to pursue doctoral studies in math and (assuming that my grades continue to stay on track) I know I will be able to satisfy that. 

My question is, are my grades able to become competitive enough to reasonably pursue a career as a tenure-track professor in math at a state university? I still have two years of undergraduate coursework plus all of graduate school and post-doc studies to make myself more appealing, but if I've already caused too much harm to repair then I'll probably skip graduate school altogether and go into industry as a software engineer. 

I don't know all that much about expectations and qualifications for becoming a mathematics professor so I was hoping that somebody who might be a little more knowledgeable here could help give me some guidance.
You shouldn't give up hope yet, and you should follow your dream while having a backup plan or two in case things don't work out.  

Nothing that you've written rules out the possibility of your going on to graduate school, but it also isn't sufficient to ensure that you will be adequately prepared for admission to graduate study in mathematics.  What you do in the next few years will determine whether or not this is possible.  

There are many more steps beyond simply getting admitted to a graduate program and it's way too early to predict things will ultimately work out for you.  Take it one step at a time, and be prepared to reassess your goals in light of your future successes and failures.