shill: DHCPConfig: Don't crash if proxy_ is NULL in RenewIP

Now that we call RenewIP on resume-from-suspend, we need to
catch cases where proxy_ is NULL in this call, since it is
possible that we have not acquired the proxy by the time we
go into suspend.

BUG=chromium-os:33648
TEST=New expectation in unit test.

Change-Id: Iefe01ec5500d0223cd65ec295023193e25f63cdd
Reviewed-on: https://gerrit.chromium.org/gerrit/30791
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/dhcp_config.cc b/dhcp_config.cc
index 0924ea2..05cbdb5 100644
--- a/dhcp_config.cc
+++ b/dhcp_config.cc
@@ -109,6 +109,10 @@
   if (!pid_) {
     return false;
   }
+  if (!proxy_.get()) {
+    LOG(ERROR) << "Unable to renew IP before acquiring destination.";
+    return false;
+  }
   proxy_->Rebind(device_name());
   StartDHCPTimeout();
   return true;
diff --git a/dhcp_config_unittest.cc b/dhcp_config_unittest.cc
index 31a3b59..4bfcfb0 100644
--- a/dhcp_config_unittest.cc
+++ b/dhcp_config_unittest.cc
@@ -399,6 +399,7 @@
 TEST_F(DHCPConfigTest, RenewIP) {
   EXPECT_TRUE(config_->lease_acquisition_timeout_callback_.IsCancelled());
   config_->pid_ = 456;
+  EXPECT_FALSE(config_->RenewIP());  // Expect no crash with NULL proxy.
   EXPECT_CALL(*proxy_, Rebind(kDeviceName)).Times(1);
   config_->proxy_.reset(proxy_.release());
   EXPECT_TRUE(config_->RenewIP());