efi_test.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /*
  2. * EFI Test Driver for Runtime Services
  3. *
  4. * Copyright(C) 2012-2016 Canonical Ltd.
  5. *
  6. * This driver exports EFI runtime services interfaces into userspace, which
  7. * allow to use and test UEFI runtime services provided by firmware.
  8. *
  9. */
  10. #include <linux/miscdevice.h>
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/proc_fs.h>
  14. #include <linux/efi.h>
  15. #include <linux/slab.h>
  16. #include <linux/uaccess.h>
  17. #include "efi_test.h"
  18. MODULE_AUTHOR("Ivan Hu <ivan.hu@canonical.com>");
  19. MODULE_DESCRIPTION("EFI Test Driver");
  20. MODULE_LICENSE("GPL");
  21. /*
  22. * Count the bytes in 'str', including the terminating NULL.
  23. *
  24. * Note this function returns the number of *bytes*, not the number of
  25. * ucs2 characters.
  26. */
  27. static inline size_t user_ucs2_strsize(efi_char16_t __user *str)
  28. {
  29. efi_char16_t *s = str, c;
  30. size_t len;
  31. if (!str)
  32. return 0;
  33. /* Include terminating NULL */
  34. len = sizeof(efi_char16_t);
  35. if (get_user(c, s++)) {
  36. /* Can't read userspace memory for size */
  37. return 0;
  38. }
  39. while (c != 0) {
  40. if (get_user(c, s++)) {
  41. /* Can't read userspace memory for size */
  42. return 0;
  43. }
  44. len += sizeof(efi_char16_t);
  45. }
  46. return len;
  47. }
  48. /*
  49. * Allocate a buffer and copy a ucs2 string from user space into it.
  50. */
  51. static inline int
  52. copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
  53. size_t len)
  54. {
  55. efi_char16_t *buf;
  56. if (!src) {
  57. *dst = NULL;
  58. return 0;
  59. }
  60. if (!access_ok(VERIFY_READ, src, 1))
  61. return -EFAULT;
  62. buf = memdup_user(src, len);
  63. if (IS_ERR(buf)) {
  64. *dst = NULL;
  65. return PTR_ERR(buf);
  66. }
  67. *dst = buf;
  68. return 0;
  69. }
  70. /*
  71. * Count the bytes in 'str', including the terminating NULL.
  72. *
  73. * Just a wrap for user_ucs2_strsize
  74. */
  75. static inline int
  76. get_ucs2_strsize_from_user(efi_char16_t __user *src, size_t *len)
  77. {
  78. if (!access_ok(VERIFY_READ, src, 1))
  79. return -EFAULT;
  80. *len = user_ucs2_strsize(src);
  81. if (*len == 0)
  82. return -EFAULT;
  83. return 0;
  84. }
  85. /*
  86. * Calculate the required buffer allocation size and copy a ucs2 string
  87. * from user space into it.
  88. *
  89. * This function differs from copy_ucs2_from_user_len() because it
  90. * calculates the size of the buffer to allocate by taking the length of
  91. * the string 'src'.
  92. *
  93. * If a non-zero value is returned, the caller MUST NOT access 'dst'.
  94. *
  95. * It is the caller's responsibility to free 'dst'.
  96. */
  97. static inline int
  98. copy_ucs2_from_user(efi_char16_t **dst, efi_char16_t __user *src)
  99. {
  100. size_t len;
  101. if (!access_ok(VERIFY_READ, src, 1))
  102. return -EFAULT;
  103. len = user_ucs2_strsize(src);
  104. if (len == 0)
  105. return -EFAULT;
  106. return copy_ucs2_from_user_len(dst, src, len);
  107. }
  108. /*
  109. * Copy a ucs2 string to a user buffer.
  110. *
  111. * This function is a simple wrapper around copy_to_user() that does
  112. * nothing if 'src' is NULL, which is useful for reducing the amount of
  113. * NULL checking the caller has to do.
  114. *
  115. * 'len' specifies the number of bytes to copy.
  116. */
  117. static inline int
  118. copy_ucs2_to_user_len(efi_char16_t __user *dst, efi_char16_t *src, size_t len)
  119. {
  120. if (!src)
  121. return 0;
  122. if (!access_ok(VERIFY_WRITE, dst, 1))
  123. return -EFAULT;
  124. return copy_to_user(dst, src, len);
  125. }
  126. static long efi_runtime_get_variable(unsigned long arg)
  127. {
  128. struct efi_getvariable __user *getvariable_user;
  129. struct efi_getvariable getvariable;
  130. unsigned long datasize = 0, prev_datasize, *dz;
  131. efi_guid_t vendor_guid, *vd = NULL;
  132. efi_status_t status;
  133. efi_char16_t *name = NULL;
  134. u32 attr, *at;
  135. void *data = NULL;
  136. int rv = 0;
  137. getvariable_user = (struct efi_getvariable __user *)arg;
  138. if (copy_from_user(&getvariable, getvariable_user,
  139. sizeof(getvariable)))
  140. return -EFAULT;
  141. if (getvariable.data_size &&
  142. get_user(datasize, getvariable.data_size))
  143. return -EFAULT;
  144. if (getvariable.vendor_guid) {
  145. if (copy_from_user(&vendor_guid, getvariable.vendor_guid,
  146. sizeof(vendor_guid)))
  147. return -EFAULT;
  148. vd = &vendor_guid;
  149. }
  150. if (getvariable.variable_name) {
  151. rv = copy_ucs2_from_user(&name, getvariable.variable_name);
  152. if (rv)
  153. return rv;
  154. }
  155. at = getvariable.attributes ? &attr : NULL;
  156. dz = getvariable.data_size ? &datasize : NULL;
  157. if (getvariable.data_size && getvariable.data) {
  158. data = kmalloc(datasize, GFP_KERNEL);
  159. if (!data) {
  160. kfree(name);
  161. return -ENOMEM;
  162. }
  163. }
  164. prev_datasize = datasize;
  165. status = efi.get_variable(name, vd, at, dz, data);
  166. kfree(name);
  167. if (put_user(status, getvariable.status)) {
  168. rv = -EFAULT;
  169. goto out;
  170. }
  171. if (status != EFI_SUCCESS) {
  172. if (status == EFI_BUFFER_TOO_SMALL) {
  173. if (dz && put_user(datasize, getvariable.data_size)) {
  174. rv = -EFAULT;
  175. goto out;
  176. }
  177. }
  178. rv = -EINVAL;
  179. goto out;
  180. }
  181. if (prev_datasize < datasize) {
  182. rv = -EINVAL;
  183. goto out;
  184. }
  185. if (data) {
  186. if (copy_to_user(getvariable.data, data, datasize)) {
  187. rv = -EFAULT;
  188. goto out;
  189. }
  190. }
  191. if (at && put_user(attr, getvariable.attributes)) {
  192. rv = -EFAULT;
  193. goto out;
  194. }
  195. if (dz && put_user(datasize, getvariable.data_size))
  196. rv = -EFAULT;
  197. out:
  198. kfree(data);
  199. return rv;
  200. }
  201. static long efi_runtime_set_variable(unsigned long arg)
  202. {
  203. struct efi_setvariable __user *setvariable_user;
  204. struct efi_setvariable setvariable;
  205. efi_guid_t vendor_guid;
  206. efi_status_t status;
  207. efi_char16_t *name = NULL;
  208. void *data;
  209. int rv = 0;
  210. setvariable_user = (struct efi_setvariable __user *)arg;
  211. if (copy_from_user(&setvariable, setvariable_user, sizeof(setvariable)))
  212. return -EFAULT;
  213. if (copy_from_user(&vendor_guid, setvariable.vendor_guid,
  214. sizeof(vendor_guid)))
  215. return -EFAULT;
  216. if (setvariable.variable_name) {
  217. rv = copy_ucs2_from_user(&name, setvariable.variable_name);
  218. if (rv)
  219. return rv;
  220. }
  221. data = memdup_user(setvariable.data, setvariable.data_size);
  222. if (IS_ERR(data)) {
  223. kfree(name);
  224. return PTR_ERR(data);
  225. }
  226. status = efi.set_variable(name, &vendor_guid,
  227. setvariable.attributes,
  228. setvariable.data_size, data);
  229. if (put_user(status, setvariable.status)) {
  230. rv = -EFAULT;
  231. goto out;
  232. }
  233. rv = status == EFI_SUCCESS ? 0 : -EINVAL;
  234. out:
  235. kfree(data);
  236. kfree(name);
  237. return rv;
  238. }
  239. static long efi_runtime_get_time(unsigned long arg)
  240. {
  241. struct efi_gettime __user *gettime_user;
  242. struct efi_gettime gettime;
  243. efi_status_t status;
  244. efi_time_cap_t cap;
  245. efi_time_t efi_time;
  246. gettime_user = (struct efi_gettime __user *)arg;
  247. if (copy_from_user(&gettime, gettime_user, sizeof(gettime)))
  248. return -EFAULT;
  249. status = efi.get_time(gettime.time ? &efi_time : NULL,
  250. gettime.capabilities ? &cap : NULL);
  251. if (put_user(status, gettime.status))
  252. return -EFAULT;
  253. if (status != EFI_SUCCESS)
  254. return -EINVAL;
  255. if (gettime.capabilities) {
  256. efi_time_cap_t __user *cap_local;
  257. cap_local = (efi_time_cap_t *)gettime.capabilities;
  258. if (put_user(cap.resolution, &(cap_local->resolution)) ||
  259. put_user(cap.accuracy, &(cap_local->accuracy)) ||
  260. put_user(cap.sets_to_zero, &(cap_local->sets_to_zero)))
  261. return -EFAULT;
  262. }
  263. if (gettime.time) {
  264. if (copy_to_user(gettime.time, &efi_time, sizeof(efi_time_t)))
  265. return -EFAULT;
  266. }
  267. return 0;
  268. }
  269. static long efi_runtime_set_time(unsigned long arg)
  270. {
  271. struct efi_settime __user *settime_user;
  272. struct efi_settime settime;
  273. efi_status_t status;
  274. efi_time_t efi_time;
  275. settime_user = (struct efi_settime __user *)arg;
  276. if (copy_from_user(&settime, settime_user, sizeof(settime)))
  277. return -EFAULT;
  278. if (copy_from_user(&efi_time, settime.time,
  279. sizeof(efi_time_t)))
  280. return -EFAULT;
  281. status = efi.set_time(&efi_time);
  282. if (put_user(status, settime.status))
  283. return -EFAULT;
  284. return status == EFI_SUCCESS ? 0 : -EINVAL;
  285. }
  286. static long efi_runtime_get_waketime(unsigned long arg)
  287. {
  288. struct efi_getwakeuptime __user *getwakeuptime_user;
  289. struct efi_getwakeuptime getwakeuptime;
  290. efi_bool_t enabled, pending;
  291. efi_status_t status;
  292. efi_time_t efi_time;
  293. getwakeuptime_user = (struct efi_getwakeuptime __user *)arg;
  294. if (copy_from_user(&getwakeuptime, getwakeuptime_user,
  295. sizeof(getwakeuptime)))
  296. return -EFAULT;
  297. status = efi.get_wakeup_time(
  298. getwakeuptime.enabled ? (efi_bool_t *)&enabled : NULL,
  299. getwakeuptime.pending ? (efi_bool_t *)&pending : NULL,
  300. getwakeuptime.time ? &efi_time : NULL);
  301. if (put_user(status, getwakeuptime.status))
  302. return -EFAULT;
  303. if (status != EFI_SUCCESS)
  304. return -EINVAL;
  305. if (getwakeuptime.enabled && put_user(enabled,
  306. getwakeuptime.enabled))
  307. return -EFAULT;
  308. if (getwakeuptime.time) {
  309. if (copy_to_user(getwakeuptime.time, &efi_time,
  310. sizeof(efi_time_t)))
  311. return -EFAULT;
  312. }
  313. return 0;
  314. }
  315. static long efi_runtime_set_waketime(unsigned long arg)
  316. {
  317. struct efi_setwakeuptime __user *setwakeuptime_user;
  318. struct efi_setwakeuptime setwakeuptime;
  319. efi_bool_t enabled;
  320. efi_status_t status;
  321. efi_time_t efi_time;
  322. setwakeuptime_user = (struct efi_setwakeuptime __user *)arg;
  323. if (copy_from_user(&setwakeuptime, setwakeuptime_user,
  324. sizeof(setwakeuptime)))
  325. return -EFAULT;
  326. enabled = setwakeuptime.enabled;
  327. if (setwakeuptime.time) {
  328. if (copy_from_user(&efi_time, setwakeuptime.time,
  329. sizeof(efi_time_t)))
  330. return -EFAULT;
  331. status = efi.set_wakeup_time(enabled, &efi_time);
  332. } else
  333. status = efi.set_wakeup_time(enabled, NULL);
  334. if (put_user(status, setwakeuptime.status))
  335. return -EFAULT;
  336. return status == EFI_SUCCESS ? 0 : -EINVAL;
  337. }
  338. static long efi_runtime_get_nextvariablename(unsigned long arg)
  339. {
  340. struct efi_getnextvariablename __user *getnextvariablename_user;
  341. struct efi_getnextvariablename getnextvariablename;
  342. unsigned long name_size, prev_name_size = 0, *ns = NULL;
  343. efi_status_t status;
  344. efi_guid_t *vd = NULL;
  345. efi_guid_t vendor_guid;
  346. efi_char16_t *name = NULL;
  347. int rv = 0;
  348. getnextvariablename_user = (struct efi_getnextvariablename __user *)arg;
  349. if (copy_from_user(&getnextvariablename, getnextvariablename_user,
  350. sizeof(getnextvariablename)))
  351. return -EFAULT;
  352. if (getnextvariablename.variable_name_size) {
  353. if (get_user(name_size, getnextvariablename.variable_name_size))
  354. return -EFAULT;
  355. ns = &name_size;
  356. prev_name_size = name_size;
  357. }
  358. if (getnextvariablename.vendor_guid) {
  359. if (copy_from_user(&vendor_guid,
  360. getnextvariablename.vendor_guid,
  361. sizeof(vendor_guid)))
  362. return -EFAULT;
  363. vd = &vendor_guid;
  364. }
  365. if (getnextvariablename.variable_name) {
  366. size_t name_string_size = 0;
  367. rv = get_ucs2_strsize_from_user(
  368. getnextvariablename.variable_name,
  369. &name_string_size);
  370. if (rv)
  371. return rv;
  372. /*
  373. * The name_size may be smaller than the real buffer size where
  374. * variable name located in some use cases. The most typical
  375. * case is passing a 0 to get the required buffer size for the
  376. * 1st time call. So we need to copy the content from user
  377. * space for at least the string size of variable name, or else
  378. * the name passed to UEFI may not be terminated as we expected.
  379. */
  380. rv = copy_ucs2_from_user_len(&name,
  381. getnextvariablename.variable_name,
  382. prev_name_size > name_string_size ?
  383. prev_name_size : name_string_size);
  384. if (rv)
  385. return rv;
  386. }
  387. status = efi.get_next_variable(ns, name, vd);
  388. if (put_user(status, getnextvariablename.status)) {
  389. rv = -EFAULT;
  390. goto out;
  391. }
  392. if (status != EFI_SUCCESS) {
  393. if (status == EFI_BUFFER_TOO_SMALL) {
  394. if (ns && put_user(*ns,
  395. getnextvariablename.variable_name_size)) {
  396. rv = -EFAULT;
  397. goto out;
  398. }
  399. }
  400. rv = -EINVAL;
  401. goto out;
  402. }
  403. if (name) {
  404. if (copy_ucs2_to_user_len(getnextvariablename.variable_name,
  405. name, prev_name_size)) {
  406. rv = -EFAULT;
  407. goto out;
  408. }
  409. }
  410. if (ns) {
  411. if (put_user(*ns, getnextvariablename.variable_name_size)) {
  412. rv = -EFAULT;
  413. goto out;
  414. }
  415. }
  416. if (vd) {
  417. if (copy_to_user(getnextvariablename.vendor_guid, vd,
  418. sizeof(efi_guid_t)))
  419. rv = -EFAULT;
  420. }
  421. out:
  422. kfree(name);
  423. return rv;
  424. }
  425. static long efi_runtime_get_nexthighmonocount(unsigned long arg)
  426. {
  427. struct efi_getnexthighmonotoniccount __user *getnexthighmonocount_user;
  428. struct efi_getnexthighmonotoniccount getnexthighmonocount;
  429. efi_status_t status;
  430. u32 count;
  431. getnexthighmonocount_user = (struct
  432. efi_getnexthighmonotoniccount __user *)arg;
  433. if (copy_from_user(&getnexthighmonocount,
  434. getnexthighmonocount_user,
  435. sizeof(getnexthighmonocount)))
  436. return -EFAULT;
  437. status = efi.get_next_high_mono_count(
  438. getnexthighmonocount.high_count ? &count : NULL);
  439. if (put_user(status, getnexthighmonocount.status))
  440. return -EFAULT;
  441. if (status != EFI_SUCCESS)
  442. return -EINVAL;
  443. if (getnexthighmonocount.high_count &&
  444. put_user(count, getnexthighmonocount.high_count))
  445. return -EFAULT;
  446. return 0;
  447. }
  448. static long efi_runtime_query_variableinfo(unsigned long arg)
  449. {
  450. struct efi_queryvariableinfo __user *queryvariableinfo_user;
  451. struct efi_queryvariableinfo queryvariableinfo;
  452. efi_status_t status;
  453. u64 max_storage, remaining, max_size;
  454. queryvariableinfo_user = (struct efi_queryvariableinfo __user *)arg;
  455. if (copy_from_user(&queryvariableinfo, queryvariableinfo_user,
  456. sizeof(queryvariableinfo)))
  457. return -EFAULT;
  458. status = efi.query_variable_info(queryvariableinfo.attributes,
  459. &max_storage, &remaining, &max_size);
  460. if (put_user(status, queryvariableinfo.status))
  461. return -EFAULT;
  462. if (status != EFI_SUCCESS)
  463. return -EINVAL;
  464. if (put_user(max_storage,
  465. queryvariableinfo.maximum_variable_storage_size))
  466. return -EFAULT;
  467. if (put_user(remaining,
  468. queryvariableinfo.remaining_variable_storage_size))
  469. return -EFAULT;
  470. if (put_user(max_size, queryvariableinfo.maximum_variable_size))
  471. return -EFAULT;
  472. return 0;
  473. }
  474. static long efi_runtime_query_capsulecaps(unsigned long arg)
  475. {
  476. struct efi_querycapsulecapabilities __user *qcaps_user;
  477. struct efi_querycapsulecapabilities qcaps;
  478. efi_capsule_header_t *capsules;
  479. efi_status_t status;
  480. u64 max_size;
  481. int i, reset_type;
  482. int rv = 0;
  483. qcaps_user = (struct efi_querycapsulecapabilities __user *)arg;
  484. if (copy_from_user(&qcaps, qcaps_user, sizeof(qcaps)))
  485. return -EFAULT;
  486. if (qcaps.capsule_count == ULONG_MAX)
  487. return -EINVAL;
  488. capsules = kcalloc(qcaps.capsule_count + 1,
  489. sizeof(efi_capsule_header_t), GFP_KERNEL);
  490. if (!capsules)
  491. return -ENOMEM;
  492. for (i = 0; i < qcaps.capsule_count; i++) {
  493. efi_capsule_header_t *c;
  494. /*
  495. * We cannot dereference qcaps.capsule_header_array directly to
  496. * obtain the address of the capsule as it resides in the
  497. * user space
  498. */
  499. if (get_user(c, qcaps.capsule_header_array + i)) {
  500. rv = -EFAULT;
  501. goto out;
  502. }
  503. if (copy_from_user(&capsules[i], c,
  504. sizeof(efi_capsule_header_t))) {
  505. rv = -EFAULT;
  506. goto out;
  507. }
  508. }
  509. qcaps.capsule_header_array = &capsules;
  510. status = efi.query_capsule_caps((efi_capsule_header_t **)
  511. qcaps.capsule_header_array,
  512. qcaps.capsule_count,
  513. &max_size, &reset_type);
  514. if (put_user(status, qcaps.status)) {
  515. rv = -EFAULT;
  516. goto out;
  517. }
  518. if (status != EFI_SUCCESS) {
  519. rv = -EINVAL;
  520. goto out;
  521. }
  522. if (put_user(max_size, qcaps.maximum_capsule_size)) {
  523. rv = -EFAULT;
  524. goto out;
  525. }
  526. if (put_user(reset_type, qcaps.reset_type))
  527. rv = -EFAULT;
  528. out:
  529. kfree(capsules);
  530. return rv;
  531. }
  532. static long efi_test_ioctl(struct file *file, unsigned int cmd,
  533. unsigned long arg)
  534. {
  535. switch (cmd) {
  536. case EFI_RUNTIME_GET_VARIABLE:
  537. return efi_runtime_get_variable(arg);
  538. case EFI_RUNTIME_SET_VARIABLE:
  539. return efi_runtime_set_variable(arg);
  540. case EFI_RUNTIME_GET_TIME:
  541. return efi_runtime_get_time(arg);
  542. case EFI_RUNTIME_SET_TIME:
  543. return efi_runtime_set_time(arg);
  544. case EFI_RUNTIME_GET_WAKETIME:
  545. return efi_runtime_get_waketime(arg);
  546. case EFI_RUNTIME_SET_WAKETIME:
  547. return efi_runtime_set_waketime(arg);
  548. case EFI_RUNTIME_GET_NEXTVARIABLENAME:
  549. return efi_runtime_get_nextvariablename(arg);
  550. case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT:
  551. return efi_runtime_get_nexthighmonocount(arg);
  552. case EFI_RUNTIME_QUERY_VARIABLEINFO:
  553. return efi_runtime_query_variableinfo(arg);
  554. case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES:
  555. return efi_runtime_query_capsulecaps(arg);
  556. }
  557. return -ENOTTY;
  558. }
  559. static int efi_test_open(struct inode *inode, struct file *file)
  560. {
  561. /*
  562. * nothing special to do here
  563. * We do accept multiple open files at the same time as we
  564. * synchronize on the per call operation.
  565. */
  566. return 0;
  567. }
  568. static int efi_test_close(struct inode *inode, struct file *file)
  569. {
  570. return 0;
  571. }
  572. /*
  573. * The various file operations we support.
  574. */
  575. static const struct file_operations efi_test_fops = {
  576. .owner = THIS_MODULE,
  577. .unlocked_ioctl = efi_test_ioctl,
  578. .open = efi_test_open,
  579. .release = efi_test_close,
  580. .llseek = no_llseek,
  581. };
  582. static struct miscdevice efi_test_dev = {
  583. MISC_DYNAMIC_MINOR,
  584. "efi_test",
  585. &efi_test_fops
  586. };
  587. static int __init efi_test_init(void)
  588. {
  589. int ret;
  590. ret = misc_register(&efi_test_dev);
  591. if (ret) {
  592. pr_err("efi_test: can't misc_register on minor=%d\n",
  593. MISC_DYNAMIC_MINOR);
  594. return ret;
  595. }
  596. return 0;
  597. }
  598. static void __exit efi_test_exit(void)
  599. {
  600. misc_deregister(&efi_test_dev);
  601. }
  602. module_init(efi_test_init);
  603. module_exit(efi_test_exit);