NULL check before pointer dereference

The function EVP_CIPHER_CTX_set_padding() is called with ctx.get()
before checking ctx for NULL. The NULL check is performed after the
function.
This commit moves the NULL check before Function call.

Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com>
Change-Id: If8f3b78d2e33c216adac9da54bdc22079435aad4
diff --git a/user_channel/passwd_mgr.cpp b/user_channel/passwd_mgr.cpp
index 939f48f..c5323fe 100644
--- a/user_channel/passwd_mgr.cpp
+++ b/user_channel/passwd_mgr.cpp
@@ -175,7 +175,6 @@
 
     std::unique_ptr<EVP_CIPHER_CTX, decltype(&::EVP_CIPHER_CTX_free)> ctx(
         EVP_CIPHER_CTX_new(), ::EVP_CIPHER_CTX_free);
-    EVP_CIPHER_CTX_set_padding(ctx.get(), 1);
 
     if (!ctx)
     {
@@ -183,6 +182,8 @@
         return -ENOMEM;
     }
 
+    EVP_CIPHER_CTX_set_padding(ctx.get(), 1);
+
     // Set key & IV
     int retval = EVP_CipherInit_ex(ctx.get(), cipher, NULL, key, iv,
                                    static_cast<int>(doEncrypt));