Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Don't panic with invalid user data, just return ...
details: https://anonhg.NetBSD.org/src/rev/71f586f4d520
branches: trunk
changeset: 373212:71f586f4d520
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Tue Jan 24 07:09:48 2023 +0000
description:
Don't panic with invalid user data, just return an error.
diffstat:
sys/dev/i2c/ds1307.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diffs (33 lines):
diff -r 089ae0e557d1 -r 71f586f4d520 sys/dev/i2c/ds1307.c
--- a/sys/dev/i2c/ds1307.c Tue Jan 24 07:04:27 2023 +0000
+++ b/sys/dev/i2c/ds1307.c Tue Jan 24 07:09:48 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ds1307.c,v 1.39 2021/08/03 23:12:14 andvar Exp $ */
+/* $NetBSD: ds1307.c,v 1.40 2023/01/24 07:09:48 mlelstv Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.39 2021/08/03 23:12:14 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.40 2023/01/24 07:09:48 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -411,13 +411,12 @@
return ENXIO;
const struct dsrtc_model * const dm = &sc->sc_model;
- if (uio->uio_offset >= dm->dm_nvram_size)
+ if (uio->uio_offset < 0 || uio->uio_offset >= dm->dm_nvram_size)
return EINVAL;
if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return error;
- KASSERT(uio->uio_offset >= 0);
while (uio->uio_resid && uio->uio_offset < dm->dm_nvram_size) {
uint8_t ch, cmd;
const u_int a = uio->uio_offset;
Home |
Main Index |
Thread Index |
Old Index