File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,27 +183,58 @@ _check_dmesg() {
183183 fi
184184}
185185
186- _setup_kmemleak () {
187- local f=" /sys/kernel/debug/kmemleak"
186+ # Retrieve the value of kernel option $1.
187+ _get_kernel_option () {
188+ local f opt=$1 result
189+
190+ for f in /proc/config.gz /boot/config-$( uname -r) ; do
191+ [ -e " $f " ] || continue
192+ if result=$( zgrep " ^CONFIG_${opt} =" " $f " ) ; then
193+ echo " ${result#* =} "
194+ return 0
195+ fi
196+ done
188197
189- if [[ ! -e $f || ! -r $f ]]; then
190- return 0
198+ return 1
199+ }
200+
201+ # Check if kernel option $1 is defined.
202+ _check_kernel_option () {
203+ case " $( _get_kernel_option " $1 " ) " in
204+ y|m)
205+ return 0;;
206+ esac
207+
208+ return 1
209+ }
210+
211+ declare KMEMLEAK=0
212+ declare KMEMLEAK_FILE=/sys/kernel/debug/kmemleak
213+
214+ if _check_kernel_option DEBUG_KMEMLEAK && [[ -e $KMEMLEAK_FILE && -r $KMEMLEAK_FILE ]]; then
215+ if _check_kernel_option DEBUG_KMEMLEAK_DEFAULT_OFF; then
216+ if grep --quiet kmemleak=on /proc/cmdline; then
217+ KMEMLEAK=1
218+ fi
219+ else
220+ KMEMLEAK=1
191221 fi
222+ fi
192223
193- echo clear > " $f "
224+ _setup_kmemleak () {
225+ if (( KMEMLEAK)) ; then
226+ echo clear > " $KMEMLEAK_FILE "
227+ fi
194228}
195229
196230_check_kmemleak () {
197231 local kmemleak
198- local f=" /sys/kernel/debug/kmemleak"
199232
200- if [[ ! -e $f || ! -r $f ]]; then
201- return 0
202- fi
233+ (( KMEMLEAK)) || return 0
203234
204- echo scan > " $f "
235+ echo scan > " $KMEMLEAK_FILE "
205236 sleep 1
206- kmemleak=$( cat " $f " )
237+ kmemleak=$( cat " $KMEMLEAK_FILE " )
207238
208239 if [[ -z $kmemleak ]]; then
209240 return 0
Original file line number Diff line number Diff line change @@ -211,31 +211,6 @@ _have_kernel_config_file() {
211211 return 0
212212}
213213
214- # Retrieve the value of kernel option $1.
215- _get_kernel_option () {
216- local f opt=$1 result
217-
218- for f in /proc/config.gz /boot/config-$( uname -r) ; do
219- [ -e " $f " ] || continue
220- if result=$( zgrep " ^CONFIG_${opt} =" " $f " ) ; then
221- echo " ${result#* =} "
222- return 0
223- fi
224- done
225-
226- return 1
227- }
228-
229- # Check if kernel option $1 is defined.
230- _check_kernel_option () {
231- case " $( _get_kernel_option " $1 " ) " in
232- y|m)
233- return 0;;
234- esac
235-
236- return 1
237- }
238-
239214# Combine _have_kernel_config_file() and _check_kernel_option().
240215# Set SKIP_REASONS when _check_kernel_option() returns false.
241216_have_kernel_option () {
You can’t perform that action at this time.
0 commit comments