Commit eb120c2a authored by Jialin Zhang's avatar Jialin Zhang Committed by Zheng Zengkai
Browse files

kabi: fix split error of kABI reference checking tool

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4JZ0H


CVE: NA

-------------------------------

Use the kABI reference checking tool as follows:

  ./scripts/check-kabi -k Module.symvers.baseline -s Module.symvers

A python error occurred, and the following traceback is printed:

Traceback (most recent call last):
  File "./scripts/check-kabi", line 144, in <module>
    load_symvers(symvers,symvers_file)
  File "./scripts/check-kabi", line 45, in load_symvers
    checksum,symbol,directory,type = string.split(in_line)
ValueError: too many values to unpack

It is because the Module.symvers file change its line format in
the following commits, and the namespace field may be empty:
cb9b55d2 ("modpost: add support for symbol namespaces")
5190044c ("modpost: move the namespace field in Module.symvers last")

In order to solve this problem, use '\t' to split each line and
add a variable to save namespace.

Fixes: 9fc7fbaf ("kabi: add kABI reference checking tool")
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarWei Li <liwei391@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 28489be2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ def load_symvers(symvers,filename):
			break
		if in_line == "\n":
			continue
		checksum,symbol,directory,type = string.split(in_line)
		checksum,symbol,directory,type,namespace = string.split(in_line, sep='\t')

		symvers[symbol] = in_line[0:-1]

@@ -57,7 +57,7 @@ def load_kabi(kabi,filename):
			break
		if in_line == "\n":
			continue
		checksum,symbol,directory,type = string.split(in_line)
		checksum,symbol,directory,type,namespace = string.split(in_line, sep='\t')

		kabi[symbol] = in_line[0:-1]

@@ -70,9 +70,9 @@ def check_kabi(symvers,kabi):
	moved_symbols=[]

	for symbol in kabi:
		abi_hash,abi_sym,abi_dir,abi_type = string.split(kabi[symbol])
		abi_hash,abi_sym,abi_dir,abi_type,namespace = string.split(kabi[symbol], sep='\t')
		if symvers.has_key(symbol):
			sym_hash,sym_sym,sym_dir,sym_type = string.split(symvers[symbol])
			sym_hash,sym_sym,sym_dir,sym_type,namespace = string.split(symvers[symbol], sep='\t')
			if abi_hash != sym_hash:
				fail=1
				changed_symbols.append(symbol)