Use `malloc` function attribute

Open
#479 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@crims0n is already working on this.

Since Nov 4, 2026.

  • #489 by @crims0n — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
tooling

Research direction

The payload names no source files. Start by finding allocation functions in the C sources whose memory is released by a matching deallocation function, then read the GCC malloc attribute documentation linked in the issue. Done when the attribute is applied to those allocators and the project builds with warnings enabled.

Written by the indexing model from the issue text.

Description

good first issue

For a while now gcc (and likely clang) has malloc (deallocator, ptr-index) (see the docs) which allows us to annotate the deallocation function which should be used.

Effectively allowing the compiler to warn on issues like https://github.com/kmod-project/kmod/pull/467... Mind you, I haven't checked if it will help with that specific issue but the principle idea remains.

Dominant language
C
Stars
116
Forks
70
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kmod-project/kmod

All issues in kmod-project/kmod

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.