Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
ndctl
ndctl-Check-whether-ndctl_btt_get_namespace-ret...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ndctl-Check-whether-ndctl_btt_get_namespace-returns-NULL-i.patch of Package ndctl
From 1e49f29f3b1fe7176006283c53b2912467c7c78d Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu <liuzhiqiang26@huawei.com> Date: Fri, 6 Nov 2020 17:27:35 +0800 Subject: [PATCH] Check whether ndctl_btt_get_namespace returns NULL in callers References: bsc#1170384 Patch-mainline: v71 Git-commit: 1e49f29f3b1fe7176006283c53b2912467c7c78d ndctl_btt_get_namespace() may return NULL, so we need to check return value of ndctl_btt_get_namespace() before using the return value in callers. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Link: https://lore.kernel.org/r/ef7e2548-0fdf-8472-83bc-7bcac67b4398@huawei.com --- test/libndctl.c | 16 +++++++++++----- test/parent-uuid.c | 2 +- util/json.c | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/libndctl.c b/test/libndctl.c index 994e0fadf4f7..a8db388877ca 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -983,13 +983,19 @@ static int check_pfn_create(struct ndctl_region *region, static int check_btt_size(struct ndctl_btt *btt) { + unsigned long long ns_size; + unsigned long sect_size; + unsigned long long actual, expect; + int size_select, sect_select; struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt); struct ndctl_test *test = ndctl_get_private_data(ctx); struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt); - unsigned long long ns_size = ndctl_namespace_get_size(ndns); - unsigned long sect_size = ndctl_btt_get_sector_size(btt); - unsigned long long actual, expect; - int size_select, sect_select; + + if (!ndns) + return -ENXIO; + + ns_size = ndctl_namespace_get_size(ndns); + sect_size = ndctl_btt_get_sector_size(btt); unsigned long long expect_table[][2] = { [0] = { [0] = 0x11b5400, @@ -1461,7 +1467,7 @@ static int check_btt_autodetect(struct ndctl_bus *bus, if (!ndctl_btt_is_enabled(btt)) continue; btt_ndns = ndctl_btt_get_namespace(btt); - if (strcmp(ndctl_namespace_get_devname(btt_ndns), devname) != 0) + if (!btt_ndns || strcmp(ndctl_namespace_get_devname(btt_ndns), devname) != 0) continue; fprintf(stderr, "%s: btt_ndns: %p ndns: %p\n", __func__, btt_ndns, ndns); diff --git a/test/parent-uuid.c b/test/parent-uuid.c index f41ca2c7bd75..303b30b24767 100644 --- a/test/parent-uuid.c +++ b/test/parent-uuid.c @@ -115,7 +115,7 @@ static struct ndctl_btt *check_valid_btt(struct ndctl_region *region, if (!ndctl_btt_is_enabled(btt)) continue; btt_ndns = ndctl_btt_get_namespace(btt); - if (strcmp(ndctl_namespace_get_devname(btt_ndns), + if (!btt_ndns || strcmp(ndctl_namespace_get_devname(btt_ndns), ndctl_namespace_get_devname(ndns)) != 0) continue; return btt; diff --git a/util/json.c b/util/json.c index 77bd4781551d..1392403affee 100644 --- a/util/json.c +++ b/util/json.c @@ -1004,6 +1004,9 @@ static void util_btt_badblocks_to_json(struct ndctl_btt *btt, struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt); unsigned long long begin, size; + if (!ndns) + return; + begin = ndctl_namespace_get_resource(ndns); if (begin == ULLONG_MAX) return; -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor