Merge "wcnss: Fix buffer overflow in wcnss_prealloc_get"
This commit is contained in:
commit
eb3869c6ea
3 changed files with 10 additions and 9 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <linux/wcnss_wlan.h>
|
#include <linux/wcnss_wlan.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/debugfs.h>
|
#include <linux/debugfs.h>
|
||||||
|
#include <net/cnss_prealloc.h>
|
||||||
#ifdef CONFIG_WCNSS_SKB_PRE_ALLOC
|
#ifdef CONFIG_WCNSS_SKB_PRE_ALLOC
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,7 +35,7 @@ static struct dentry *debug_base;
|
||||||
|
|
||||||
struct wcnss_prealloc {
|
struct wcnss_prealloc {
|
||||||
int occupied;
|
int occupied;
|
||||||
unsigned int size;
|
size_t size;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
#ifdef CONFIG_SLUB_DEBUG
|
#ifdef CONFIG_SLUB_DEBUG
|
||||||
unsigned long stack_trace[WCNSS_MAX_STACK_TRACE];
|
unsigned long stack_trace[WCNSS_MAX_STACK_TRACE];
|
||||||
|
@ -159,7 +160,7 @@ static inline void wcnss_prealloc_save_stack_trace(struct wcnss_prealloc *entry)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *wcnss_prealloc_get(unsigned int size)
|
void *wcnss_prealloc_get(size_t size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
@ -179,8 +180,8 @@ void *wcnss_prealloc_get(unsigned int size)
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&alloc_lock, flags);
|
spin_unlock_irqrestore(&alloc_lock, flags);
|
||||||
|
|
||||||
pr_err("wcnss: %s: prealloc not available for size: %d\n",
|
pr_err("wcnss: %s: prealloc not available for size: %zu\n",
|
||||||
__func__, size);
|
__func__, size);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -219,8 +220,8 @@ void wcnss_prealloc_check_memory_leak(void)
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_err("Size: %u, addr: %pK, backtrace:\n",
|
pr_err("Size: %zu, addr: %pK, backtrace:\n",
|
||||||
wcnss_allocs[i].size, wcnss_allocs[i].ptr);
|
wcnss_allocs[i].size, wcnss_allocs[i].ptr);
|
||||||
print_stack_trace(&wcnss_allocs[i].trace, 1);
|
print_stack_trace(&wcnss_allocs[i].trace, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ int wcnss_get_wlan_mac_address(char mac_addr[WLAN_MAC_ADDR_SIZE]);
|
||||||
void wcnss_allow_suspend(void);
|
void wcnss_allow_suspend(void);
|
||||||
void wcnss_prevent_suspend(void);
|
void wcnss_prevent_suspend(void);
|
||||||
int wcnss_hardware_type(void);
|
int wcnss_hardware_type(void);
|
||||||
void *wcnss_prealloc_get(unsigned int size);
|
void *wcnss_prealloc_get(size_t size);
|
||||||
int wcnss_prealloc_put(void *ptr);
|
int wcnss_prealloc_put(void *ptr);
|
||||||
void wcnss_reset_fiq(bool clk_chk_en);
|
void wcnss_reset_fiq(bool clk_chk_en);
|
||||||
void wcnss_suspend_notify(void);
|
void wcnss_suspend_notify(void);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#define WCNSS_PRE_ALLOC_GET_THRESHOLD (4*1024)
|
#define WCNSS_PRE_ALLOC_GET_THRESHOLD (4*1024)
|
||||||
|
|
||||||
extern void *wcnss_prealloc_get(unsigned int size);
|
extern void *wcnss_prealloc_get(size_t size);
|
||||||
extern int wcnss_prealloc_put(void *ptr);
|
extern int wcnss_prealloc_put(void *ptr);
|
||||||
extern int wcnss_pre_alloc_reset(void);
|
extern int wcnss_pre_alloc_reset(void);
|
||||||
void wcnss_prealloc_check_memory_leak(void);
|
void wcnss_prealloc_check_memory_leak(void);
|
||||||
|
|
Loading…
Add table
Reference in a new issue