-/* $OpenBSD: aplpmu.c,v 1.6 2022/10/12 13:39:50 kettenis Exp $ */
+/* $OpenBSD: aplpmu.c,v 1.7 2022/12/12 18:45:01 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
struct aplpmu_nvmem *an = cookie;
struct aplpmu_softc *sc = an->an_sc;
- if (addr >= an->an_size || addr + size > an->an_size)
+ if (addr >= an->an_size || size > an->an_size - addr)
return EINVAL;
return spmi_cmd_read(sc->sc_tag, sc->sc_sid, SPMI_CMD_EXT_READL,
struct aplpmu_nvmem *an = cookie;
struct aplpmu_softc *sc = an->an_sc;
- if (addr >= an->an_size || addr + size > an->an_size)
+ if (addr >= an->an_size || size > an->an_size - addr)
return EINVAL;
return spmi_cmd_write(sc->sc_tag, sc->sc_sid, SPMI_CMD_EXT_WRITEL,