mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
driver core: Add __alloc_size hint to devm allocators
Mark the devm_*alloc()-family of allocations with appropriate __alloc_size()/__realloc_size() hints so the compiler can attempt to reason about buffer lengths from allocations. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Nishanth Menon <nm@ti.com> Cc: Michael Kelley <mikelley@microsoft.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Won Chung <wonchung@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20221029074734.gonna.276-kees@kernel.org
This commit is contained in:
parent
8abfff25b3
commit
74c8e6bffb
@ -197,9 +197,9 @@ void devres_remove_group(struct device *dev, void *id);
|
||||
int devres_release_group(struct device *dev, void *id);
|
||||
|
||||
/* managed devm_k.alloc/kfree for device drivers */
|
||||
void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __malloc;
|
||||
void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_size(2);
|
||||
void *devm_krealloc(struct device *dev, void *ptr, size_t size,
|
||||
gfp_t gfp) __must_check;
|
||||
gfp_t gfp) __must_check __realloc_size(3);
|
||||
__printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
|
||||
const char *fmt, va_list ap) __malloc;
|
||||
__printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
|
||||
@ -226,7 +226,8 @@ static inline void *devm_kcalloc(struct device *dev,
|
||||
void devm_kfree(struct device *dev, const void *p);
|
||||
char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
|
||||
const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
|
||||
void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
|
||||
void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
|
||||
__realloc_size(3);
|
||||
|
||||
unsigned long devm_get_free_pages(struct device *dev,
|
||||
gfp_t gfp_mask, unsigned int order);
|
||||
|
Loading…
Reference in New Issue
Block a user