Skip to content

clkdev: prevent potential memory leak when used in modules

Andy Shevchenko lkml 4 versions – In review

Get series with b4
b4 am 1430907852-160833-1-git-send-email-andriy.shevchenko@linux.intel.com

Versions newest first · linked by author and title

  1. v4 Latest1 patch 4 repliesIn review
  2. v31 patch 1 replySuperseded
  3. v21 patch 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch0 repliesSuperseded

Changes in v4 from the cover letter

- rebase on recent linux-next
- add Ack from Sylwester Nawrocki

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1clkdev: change prototype of clk_register_clkdev()arch/arm/mach-vexpress/spc.c arch/mips/ath79/clock.c drivers/clk/clk-bcm2835.c +7 more+73 -544 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchMika WesterbergSylwester Nawrocki
1/1R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/1] clkdev: prevent potential memory leak when used in modules

Since clk_register_clkdev() is exported for modules the caller should get a pointer to the allocated resources. Otherwise the memory leak is guaranteed on the ->remove() stage.

The patch changes the prototype of the clk_register_clkdev() to return a pointer to the allocated resources. The caller should take care of the returned variable and free allocated resources when needed. Together with the main change the users are updated too.

The current change doesn't fix any present memory leak, thus developers and maintainers should take care of it if needed.

The patch has been tested on x86 (*), thus requires to be tested on touched architectures.

(*) On x86 there will be a user, more details at

    http://www.spinics.net/lists/kernel/msg1958587.html.

Changelog v4:
- rebase on recent linux-next
- add Ack from Sylwester Nawrocki

Changelog v3:
- fix compiler warnings
drivers/clk/samsung/clk-pll.c:1304:3: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=] drivers/clk/samsung/clk-s3c2410-dclk.c:323:3: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=] drivers/clk/samsung/clk-s3c2410-dclk.c:243:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Changelog v2:
- update inplace documentation to mention clkdev_drop() that should be used to free the resources
- mention in cover letter that we have tested it on x86
- append Mika's Reviewed-by tag
- add Russel to the Cc list
- rebase on top of 4.0-rc1

Andy Shevchenko (1):
clkdev: change prototype of clk_register_clkdev()

 arch/arm/mach-vexpress/spc.c           |  5 ++++-
 arch/mips/ath79/clock.c                |  6 +++---
 drivers/clk/clk-bcm2835.c              | 12 +++++++-----
 drivers/clk/clk-max-gen.c              |  9 ++++-----
 drivers/clk/clk-xgene.c                |  6 +++---
 drivers/clk/clkdev.c                   | 15 ++++++++++-----
 drivers/clk/samsung/clk-pll.c          | 15 +++++++++------
 drivers/clk/samsung/clk-s3c2410-dclk.c | 22 +++++++++++----------
 drivers/clk/samsung/clk.c              | 35 +++++++++++++++++++---------------
 include/linux/clkdev.h                 |  2 +-
 10 files changed, 73 insertions(+), 54 deletions(-)
Signature · 1 line
2.1.4