]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - crypto/rng.c
crypto: user - clean up report structure copying
[mirror_ubuntu-focal-kernel.git] / crypto / rng.c
index 547f16ecbfb03fceda06ca0e2d8cf0873dd4a63b..2406501b90b7036540bbfca51e08b302d3f66857 100644 (file)
@@ -74,17 +74,13 @@ static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)
 {
        struct crypto_report_rng rrng;
 
-       strncpy(rrng.type, "rng", sizeof(rrng.type));
+       memset(&rrng, 0, sizeof(rrng));
 
-       rrng.seedsize = seedsize(alg);
+       strscpy(rrng.type, "rng", sizeof(rrng.type));
 
-       if (nla_put(skb, CRYPTOCFGA_REPORT_RNG,
-                   sizeof(struct crypto_report_rng), &rrng))
-               goto nla_put_failure;
-       return 0;
+       rrng.seedsize = seedsize(alg);
 
-nla_put_failure:
-       return -EMSGSIZE;
+       return nla_put(skb, CRYPTOCFGA_REPORT_RNG, sizeof(rrng), &rrng);
 }
 #else
 static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)