Skip to content

Commit

Permalink
module: Make internal.h and decompress.c more compliant
Browse files Browse the repository at this point in the history
This patch will address the following warning and style violations
generated by ./scripts/checkpatch.pl in strict mode:

  WARNING: Use #include <linux/module.h> instead of <asm/module.h>
  torvalds#10: FILE: kernel/module/internal.h:10:
  +#include <asm/module.h>

  CHECK: spaces preferred around that '-' (ctx:VxV)
  torvalds#18: FILE: kernel/module/internal.h:18:
  +#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))

  CHECK: Please use a blank line after function/struct/union/enum declarations
  torvalds#69: FILE: kernel/module/internal.h:69:
  +}
  +static inline void module_decompress_cleanup(struct load_info *info)
						   ^
  CHECK: extern prototypes should be avoided in .h files
  torvalds#84: FILE: kernel/module/internal.h:84:
  +extern int mod_verify_sig(const void *mod, struct load_info *info);

  WARNING: Missing a blank line after declarations
  torvalds#116: FILE: kernel/module/decompress.c:116:
  +               struct page *page = module_get_next_page(info);
  +               if (!page) {

  WARNING: Missing a blank line after declarations
  torvalds#174: FILE: kernel/module/decompress.c:174:
  +               struct page *page = module_get_next_page(info);
  +               if (!page) {

  CHECK: Please use a blank line after function/struct/union/enum declarations
  torvalds#258: FILE: kernel/module/decompress.c:258:
  +}
  +static struct kobj_attribute module_compression_attr = __ATTR_RO(compression);

Note: Fortunately, the multiple-include optimisation found in
include/linux/module.h will prevent duplication/or inclusion more than
once.

Fixes: f314dfe ("modsign: log module name in the event of an error")
Reviewed-by: Christophe Leroy <[email protected]>
Signed-off-by: Aaron Tomlin <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
  • Loading branch information
Aaron Tomlin authored and mcgrof committed Feb 19, 2022
1 parent ca39c5b commit ef1be4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions kernel/module/decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ static ssize_t module_gzip_decompress(struct load_info *info,

do {
struct page *page = module_get_next_page(info);

if (!page) {
retval = -ENOMEM;
goto out_inflate_end;
Expand Down Expand Up @@ -171,6 +172,7 @@ static ssize_t module_xz_decompress(struct load_info *info,

do {
struct page *page = module_get_next_page(info);

if (!page) {
retval = -ENOMEM;
goto out;
Expand Down Expand Up @@ -256,6 +258,7 @@ static ssize_t compression_show(struct kobject *kobj,
{
return sysfs_emit(buf, "%s\n", __stringify(MODULE_COMPRESSION));
}

static struct kobj_attribute module_compression_attr = __ATTR_RO(compression);

static int __init module_decompress_sysfs_init(void)
Expand Down
6 changes: 4 additions & 2 deletions kernel/module/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

#include <linux/elf.h>
#include <asm/module.h>
#include <linux/compiler.h>
#include <linux/module.h>
#include <linux/mutex.h>

#ifndef ARCH_SHF_SMALL
Expand Down Expand Up @@ -54,7 +55,7 @@ struct load_info {
} index;
};

extern int mod_verify_sig(const void *mod, struct load_info *info);
int mod_verify_sig(const void *mod, struct load_info *info);

#ifdef CONFIG_MODULE_DECOMPRESS
int module_decompress(struct load_info *info, const void *buf, size_t size);
Expand All @@ -65,6 +66,7 @@ static inline int module_decompress(struct load_info *info,
{
return -EOPNOTSUPP;
}

static inline void module_decompress_cleanup(struct load_info *info)
{
}
Expand Down

0 comments on commit ef1be4a

Please sign in to comment.