mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 23:04:43 +00:00
debugfs: make sure we can remove u32_array files cleanly
debugfs_create_u32_array() allocates a small structure to wrap the data and size information about the array. If users ever try to remove the file this leads to a leak since nothing ever frees this wrapper. That said there are no upstream users of debugfs_create_u32_array() that'd remove a u32 array file (we only have one u32 array user in CMA), so there is no real bug here. Make callers pass a wrapper they allocated. This way the lifetime management of the wrapper is on the caller, and we can avoid the potential leak in debugfs. CC: Chucheng Luo <luochucheng@vivo.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8fb49c0109
commit
a2b992c828
5 changed files with 31 additions and 30 deletions
|
@ -38,6 +38,11 @@ struct debugfs_regset32 {
|
|||
struct device *dev; /* Optional device for Runtime PM */
|
||||
};
|
||||
|
||||
struct debugfs_u32_array {
|
||||
u32 *array;
|
||||
u32 n_elements;
|
||||
};
|
||||
|
||||
extern struct dentry *arch_debugfs_dir;
|
||||
|
||||
#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
|
||||
|
@ -136,7 +141,8 @@ void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
|
|||
int nregs, void __iomem *base, char *prefix);
|
||||
|
||||
void debugfs_create_u32_array(const char *name, umode_t mode,
|
||||
struct dentry *parent, u32 *array, u32 elements);
|
||||
struct dentry *parent,
|
||||
struct debugfs_u32_array *array);
|
||||
|
||||
struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
|
||||
struct dentry *parent,
|
||||
|
@ -316,8 +322,8 @@ static inline bool debugfs_initialized(void)
|
|||
}
|
||||
|
||||
static inline void debugfs_create_u32_array(const char *name, umode_t mode,
|
||||
struct dentry *parent, u32 *array,
|
||||
u32 elements)
|
||||
struct dentry *parent,
|
||||
struct debugfs_u32_array *array)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue