Comments (2)
Brian, thank you! For both- pointing out this bug (yes, leading to leakage at that!), and for appreciating the book..
Yeah, I guess the gptr5 confused me at some point :-) (ah the perils of variable naming!). Have just updated the fix (and mentioned you in it !).
from linux-kernel-programming.
Hi Kaiwan,
Thank you for the mention. :-)
I noticed another possible small update for the ch9 'vmalloc_demo.c' module (maybe for the next revision coming out in January). When I was typing out the code I noticed that it looks like the goto labels aren't using kvfree() for the kv/kvarr pointers, but in the module exit function kvfree() is being used (I wasn't sure if this should be updated for consistency or if it was meant to show you can use either as long as you know that kvmalloc()/vmalloc() was used to allocate a given segment of memory). :-)
<I added bold highlight around the kvfree/vfree lines in question.>
In vmalloc_try():
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
err_out5:
vfree(kvarr);
#endif
err_out4:
vfree(kv);
err_out3:
vfree(vptr_init);
err_out2:
vfree(vptr_rndm);
err_out1:
return -ENOMEM;
In vmalloc_demo_exit():
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
vfree(vrx);
#endif
kvfree(kvarr);
kvfree(kv);
vfree(vptr_init);
vfree(vptr_rndm);
pr_info("removed\n");
from linux-kernel-programming.
Related Issues (13)
- Not all recommended packages available in Ubuntu 18.04 LTS repos HOT 1
- Is it safe to iterate task list without any lock? HOT 1
- Having trouble booting the 5.4 kernel on Ubuntu Jammy 22.04 HOT 3
- ch6: viewing userspace stack for bash using gdb HOT 1
- Some typos in this book. HOT 1
- p26: "sudo apt install git fakeroot...": utillinux -> util-linux HOT 1
- is it compatible to use your first edition in ubunut 22.04 HOT 2
- Book Translation HOT 2
- Possible memory leak in ch12 mutex/spinlock examples HOT 1
- Fix for 5.7+ Linux kernel and example code for ch13 percpu_var.c HOT 3
- Missing sample code of Part 2 HOT 1
- Ch 10 Question 8 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linux-kernel-programming.