efi_test.c 16 KB

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