Improve error handling, doesn't matter a lot, but still.

This commit is contained in:
maxv 2018-12-10 07:24:49 +00:00
parent 98099c45e5
commit b5785cea53
1 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_kleak.c,v 1.1 2018/12/02 21:00:13 maxv Exp $ */
/* $NetBSD: subr_kleak.c,v 1.2 2018/12/10 07:24:49 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_kleak.c,v 1.1 2018/12/02 21:00:13 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_kleak.c,v 1.2 2018/12/10 07:24:49 maxv Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -244,17 +244,23 @@ kleak_init(void)
static int
kleak_rotate(void)
{
int error = 0;
mutex_enter(&kleak_mtx);
kleak_index++;
if (kleak_index + 1 >= kleak_nrounds) {
error = ENOENT;
} else {
kleak_index++;
}
mutex_exit(&kleak_mtx);
if (error) {
return error;
}
/* XXX: Should be atomic. */
kleak_pattern_byte = kleak_pattern_list[kleak_index];
if (kleak_index >= kleak_nrounds) {
return ENOENT;
}
return 0;
}