FIX metadata collision API

If `is_valid` was NULL, OCF would crash

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
Michal Mielewczyk 2025-03-21 09:41:28 +01:00
parent f43d53be19
commit e1d2ff12d8

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2021 Intel Corporation * Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2025 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -326,15 +327,18 @@ static inline bool metadata_clear_valid_sec_changed(
struct ocf_cache *cache, ocf_cache_line_t line, struct ocf_cache *cache, ocf_cache_line_t line,
uint8_t start, uint8_t stop, bool *is_valid) uint8_t start, uint8_t stop, bool *is_valid)
{ {
bool was_any_valid; bool was_any_valid, _line_remains_valid;
was_any_valid = ocf_metadata_test_valid(cache, line, 0, was_any_valid = ocf_metadata_test_valid(cache, line, 0,
ocf_line_end_sector(cache), false); ocf_line_end_sector(cache), false);
*is_valid = ocf_metadata_clear_valid(cache, line, _line_remains_valid = ocf_metadata_clear_valid(cache, line,
start, stop); start, stop);
return was_any_valid && !*is_valid; if (likely(is_valid))
*is_valid = _line_remains_valid;
return was_any_valid && !_line_remains_valid;
} }
#endif /* METADATA_STATUS_H_ */ #endif /* METADATA_STATUS_H_ */