/* Mutex to serialize the shared buffer access and command handling. */
 static DEFINE_MUTEX(snp_cmd_mutex);
 
-static bool is_vmpck_empty(struct snp_msg_desc *mdesc)
-{
-       char zero_key[VMPCK_KEY_LEN] = {0};
-
-       if (mdesc->vmpck)
-               return !memcmp(mdesc->vmpck, zero_key, VMPCK_KEY_LEN);
-
-       return true;
-}
-
 /*
  * If an error is received from the host or AMD Secure Processor (ASP) there
  * are two options. Either retry the exact same encrypted request or discontinue
        guard(mutex)(&snp_cmd_mutex);
 
        /* Check if the VMPCK is not empty */
-       if (is_vmpck_empty(mdesc)) {
+       if (!mdesc->vmpck || !memchr_inv(mdesc->vmpck, 0, VMPCK_KEY_LEN)) {
                pr_err_ratelimited("VMPCK is disabled\n");
                return -ENOTTY;
        }
        }
 
        /* Verify that VMPCK is not zero. */
-       if (is_vmpck_empty(mdesc)) {
+       if (!memchr_inv(mdesc->vmpck, 0, VMPCK_KEY_LEN)) {
                dev_err(dev, "Empty VMPCK%d communication key\n", vmpck_id);
                goto e_unmap;
        }