I think it might be a cleaner solution if you first implement a new function: /* * Like erst_read(), but look for a specific record type (by size and guid) * also retry -ENOENT returns by skipping to next record_id */ ssize_t erst_read_record(u64 *record_id, struct cper_record_header *record, size_t buflen, size_t recordlen, const guid_t *guid) { } Step 2: Update apei_read_mce() and erst_reader() to use this function. Step 3: Apply your erst_clear_cache() fix to the new function -Tony