From c4c82a8d8017495e8183e083e1ba26b0fc2eb2eb Mon Sep 17 00:00:00 2001 From: "Peter K. Moss" Date: Fri, 8 Jan 2021 23:50:24 +0100 Subject: Using kfree_sensitive over kzfree for kernels >= 5.9-rc1 This modification is needed for the newer kernels as per https://github.com/torvalds/linux/commit/453431a54934d917153c65211b2dabf45562ca88 --- hid-tminit.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hid-tminit.c b/hid-tminit.c index 1538bab..59905d9 100644 --- a/hid-tminit.c +++ b/hid-tminit.c @@ -15,8 +15,15 @@ #include #include #include +#include #include "hid-tminit.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,1) + #define KFREE(ptr) kfree_sensitive(ptr) +#else + #define KFREE(ptr) kzfree(ptr) +#endif + /** * On some setups initializing the T300RS crashes the kernel, * these interrupts fix that particular issue. So far they haven't caused any @@ -54,7 +61,7 @@ static void tminit_interrupts(struct hid_device *hdev){ } } - kzfree(send_buf); + KFREE(send_buf); } static void tminit_change_handler(struct urb *urb) @@ -135,10 +142,10 @@ static void tminit_remove(struct hid_device *hdev) usb_kill_urb(tm_wheel->urb); - kzfree(tm_wheel->response); - kzfree(tm_wheel->model_request); + KFREE(tm_wheel->response); + KFREE(tm_wheel->model_request); usb_free_urb(tm_wheel->urb); - kzfree(tm_wheel); + KFREE(tm_wheel); hid_hw_stop(hdev); } @@ -227,10 +234,10 @@ static int tminit_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; -error5: kzfree(tm_wheel->response); -error4: kzfree(tm_wheel->model_request); +error5: KFREE(tm_wheel->response); +error4: KFREE(tm_wheel->model_request); error3: usb_free_urb(tm_wheel->urb); -error2: kzfree(tm_wheel); +error2: KFREE(tm_wheel); error1: hid_hw_stop(hdev); error0: return ret; -- cgit v1.3 From 742420ee045c97a851ab580f01e98a79da235d65 Mon Sep 17 00:00:00 2001 From: "Peter K. Moss" Date: Sun, 10 Jan 2021 12:48:46 +0100 Subject: Using `kfree` instead of `kzfree` or `kfree_sensitive` There is no sensitive information in the driver, so using `kfree` should be fine. See https://github.com/scarburato/t150_driver/pull/11 for more information on the discussion. --- hid-tminit.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/hid-tminit.c b/hid-tminit.c index 59905d9..f7c7814 100644 --- a/hid-tminit.c +++ b/hid-tminit.c @@ -15,15 +15,8 @@ #include #include #include -#include #include "hid-tminit.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,1) - #define KFREE(ptr) kfree_sensitive(ptr) -#else - #define KFREE(ptr) kzfree(ptr) -#endif - /** * On some setups initializing the T300RS crashes the kernel, * these interrupts fix that particular issue. So far they haven't caused any @@ -61,7 +54,7 @@ static void tminit_interrupts(struct hid_device *hdev){ } } - KFREE(send_buf); + kfree(send_buf); } static void tminit_change_handler(struct urb *urb) @@ -142,10 +135,10 @@ static void tminit_remove(struct hid_device *hdev) usb_kill_urb(tm_wheel->urb); - KFREE(tm_wheel->response); - KFREE(tm_wheel->model_request); + kfree(tm_wheel->response); + kfree(tm_wheel->model_request); usb_free_urb(tm_wheel->urb); - KFREE(tm_wheel); + kfree(tm_wheel); hid_hw_stop(hdev); } @@ -234,10 +227,10 @@ static int tminit_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; -error5: KFREE(tm_wheel->response); -error4: KFREE(tm_wheel->model_request); +error5: kfree(tm_wheel->response); +error4: kfree(tm_wheel->model_request); error3: usb_free_urb(tm_wheel->urb); -error2: KFREE(tm_wheel); +error2: kfree(tm_wheel); error1: hid_hw_stop(hdev); error0: return ret; -- cgit v1.3