10
10
*/
11
11
12
12
#include <linux/bitfield.h>
13
+ #include <linux/cleanup.h>
13
14
#include <linux/clk.h>
14
15
#include <linux/io.h>
15
16
#include <linux/kernel.h>
@@ -216,7 +217,6 @@ EXPORT_SYMBOL_GPL(of_get_ocmem);
216
217
struct ocmem_buf * ocmem_allocate (struct ocmem * ocmem , enum ocmem_client client ,
217
218
unsigned long size )
218
219
{
219
- struct ocmem_buf * buf ;
220
220
int ret ;
221
221
222
222
/* TODO: add support for other clients... */
@@ -229,7 +229,7 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client,
229
229
if (test_and_set_bit_lock (BIT (client ), & ocmem -> active_allocations ))
230
230
return ERR_PTR (- EBUSY );
231
231
232
- buf = kzalloc (sizeof (* buf ), GFP_KERNEL );
232
+ struct ocmem_buf * buf __free ( kfree ) = kzalloc (sizeof (* buf ), GFP_KERNEL );
233
233
if (!buf ) {
234
234
ret = - ENOMEM ;
235
235
goto err_unlock ;
@@ -247,7 +247,7 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client,
247
247
if (ret ) {
248
248
dev_err (ocmem -> dev , "could not lock: %d\n" , ret );
249
249
ret = - EINVAL ;
250
- goto err_kfree ;
250
+ goto err_unlock ;
251
251
}
252
252
} else {
253
253
ocmem_write (ocmem , OCMEM_REG_GFX_MPU_START , buf -> offset );
@@ -258,10 +258,8 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client,
258
258
dev_dbg (ocmem -> dev , "using %ldK of OCMEM at 0x%08lx for client %d\n" ,
259
259
size / 1024 , buf -> addr , client );
260
260
261
- return buf ;
261
+ return_ptr ( buf ) ;
262
262
263
- err_kfree :
264
- kfree (buf );
265
263
err_unlock :
266
264
clear_bit_unlock (BIT (client ), & ocmem -> active_allocations );
267
265
0 commit comments