diff mbox

[ndctl,7/7] ndctl: fix unchecked return value

Message ID 146161382607.21779.2208336715925326189.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit fac9ce6bee70
Headers show

Commit Message

Dan Williams April 25, 2016, 7:50 p.m. UTC
Static analysis flags the sscanf() in get_system_kver() for return-value
checking. Fall back to the system kernel headers version.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/test/core.c b/test/core.c
index dba9c4c38ab1..b5703273fa76 100644
--- a/test/core.c
+++ b/test/core.c
@@ -19,7 +19,8 @@  static unsigned int get_system_kver(void)
 
 	uname(&utsname);
 
-	sscanf(utsname.release, "%d.%d.%d", &a, &b, &c);
+	if (sscanf(utsname.release, "%d.%d.%d", &a, &b, &c) != 3)
+		return LINUX_VERSION_CODE;
 
 	return KERNEL_VERSION(a,b,c);
 }