hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/misc/sram-exec.c
....@@ -1,7 +1,7 @@
11 /*
22 * SRAM protect-exec region helper functions
33 *
4
- * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
4
+ * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
55 * Dave Gerlach
66 *
77 * This program is free software; you can redistribute it and/or modify
....@@ -85,6 +85,7 @@
8585 unsigned long base;
8686 int pages;
8787 void *dst_cpy;
88
+ int ret;
8889
8990 mutex_lock(&exec_pool_list_mutex);
9091 list_for_each_entry(p, &exec_pool_list, list) {
....@@ -96,7 +97,7 @@
9697 if (!part)
9798 return NULL;
9899
99
- if (!addr_in_gen_pool(pool, (unsigned long)dst, size))
100
+ if (!gen_pool_has_addr(pool, (unsigned long)dst, size))
100101 return NULL;
101102
102103 base = (unsigned long)part->base;
....@@ -104,16 +105,28 @@
104105
105106 mutex_lock(&part->lock);
106107
107
- set_memory_nx((unsigned long)base, pages);
108
- set_memory_rw((unsigned long)base, pages);
108
+ ret = set_memory_nx((unsigned long)base, pages);
109
+ if (ret)
110
+ goto error_out;
111
+ ret = set_memory_rw((unsigned long)base, pages);
112
+ if (ret)
113
+ goto error_out;
109114
110115 dst_cpy = fncpy(dst, src, size);
111116
112
- set_memory_ro((unsigned long)base, pages);
113
- set_memory_x((unsigned long)base, pages);
117
+ ret = set_memory_ro((unsigned long)base, pages);
118
+ if (ret)
119
+ goto error_out;
120
+ ret = set_memory_x((unsigned long)base, pages);
121
+ if (ret)
122
+ goto error_out;
114123
115124 mutex_unlock(&part->lock);
116125
117126 return dst_cpy;
127
+
128
+error_out:
129
+ mutex_unlock(&part->lock);
130
+ return NULL;
118131 }
119132 EXPORT_SYMBOL_GPL(sram_exec_copy);