hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/virtio/virtio_crypto_core.c
....@@ -1,19 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Driver for Virtio crypto device.
23 *
34 * Copyright 2016 HUAWEI TECHNOLOGIES CO., LTD.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
175 */
186
197 #include <linux/err.h>
....@@ -29,7 +17,7 @@
2917 virtcrypto_clear_request(struct virtio_crypto_request *vc_req)
3018 {
3119 if (vc_req) {
32
- kzfree(vc_req->req_data);
20
+ kfree_sensitive(vc_req->req_data);
3321 kfree(vc_req->sgs);
3422 }
3523 }
....@@ -216,8 +204,8 @@
216204 u32 status;
217205 int err;
218206
219
- virtio_cread(vcrypto->vdev,
220
- struct virtio_crypto_config, status, &status);
207
+ virtio_cread_le(vcrypto->vdev,
208
+ struct virtio_crypto_config, status, &status);
221209
222210 /*
223211 * Unknown status bits would be a host error and the driver
....@@ -335,31 +323,31 @@
335323 if (!vcrypto)
336324 return -ENOMEM;
337325
338
- virtio_cread(vdev, struct virtio_crypto_config,
326
+ virtio_cread_le(vdev, struct virtio_crypto_config,
339327 max_dataqueues, &max_data_queues);
340328 if (max_data_queues < 1)
341329 max_data_queues = 1;
342330
343
- virtio_cread(vdev, struct virtio_crypto_config,
344
- max_cipher_key_len, &max_cipher_key_len);
345
- virtio_cread(vdev, struct virtio_crypto_config,
346
- max_auth_key_len, &max_auth_key_len);
347
- virtio_cread(vdev, struct virtio_crypto_config,
348
- max_size, &max_size);
349
- virtio_cread(vdev, struct virtio_crypto_config,
350
- crypto_services, &crypto_services);
351
- virtio_cread(vdev, struct virtio_crypto_config,
352
- cipher_algo_l, &cipher_algo_l);
353
- virtio_cread(vdev, struct virtio_crypto_config,
354
- cipher_algo_h, &cipher_algo_h);
355
- virtio_cread(vdev, struct virtio_crypto_config,
356
- hash_algo, &hash_algo);
357
- virtio_cread(vdev, struct virtio_crypto_config,
358
- mac_algo_l, &mac_algo_l);
359
- virtio_cread(vdev, struct virtio_crypto_config,
360
- mac_algo_h, &mac_algo_h);
361
- virtio_cread(vdev, struct virtio_crypto_config,
362
- aead_algo, &aead_algo);
331
+ virtio_cread_le(vdev, struct virtio_crypto_config,
332
+ max_cipher_key_len, &max_cipher_key_len);
333
+ virtio_cread_le(vdev, struct virtio_crypto_config,
334
+ max_auth_key_len, &max_auth_key_len);
335
+ virtio_cread_le(vdev, struct virtio_crypto_config,
336
+ max_size, &max_size);
337
+ virtio_cread_le(vdev, struct virtio_crypto_config,
338
+ crypto_services, &crypto_services);
339
+ virtio_cread_le(vdev, struct virtio_crypto_config,
340
+ cipher_algo_l, &cipher_algo_l);
341
+ virtio_cread_le(vdev, struct virtio_crypto_config,
342
+ cipher_algo_h, &cipher_algo_h);
343
+ virtio_cread_le(vdev, struct virtio_crypto_config,
344
+ hash_algo, &hash_algo);
345
+ virtio_cread_le(vdev, struct virtio_crypto_config,
346
+ mac_algo_l, &mac_algo_l);
347
+ virtio_cread_le(vdev, struct virtio_crypto_config,
348
+ mac_algo_h, &mac_algo_h);
349
+ virtio_cread_le(vdev, struct virtio_crypto_config,
350
+ aead_algo, &aead_algo);
363351
364352 /* Add virtio crypto device to global table */
365353 err = virtcrypto_devmgr_add_dev(vcrypto);
....@@ -510,11 +498,11 @@
510498 }
511499 #endif
512500
513
-static unsigned int features[] = {
501
+static const unsigned int features[] = {
514502 /* none */
515503 };
516504
517
-static struct virtio_device_id id_table[] = {
505
+static const struct virtio_device_id id_table[] = {
518506 { VIRTIO_ID_CRYPTO, VIRTIO_DEV_ANY_ID },
519507 { 0 },
520508 };