diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2008-07-29 19:13:20 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2008-07-29 19:13:20 +0000 |
commit | 40428850dba4039ecc7ae774d0efb2a6e49ed170 (patch) | |
tree | e77709f76e85b90af5a7b0314355b3e23ee7559a /sys/dev/pci | |
parent | 05836cb6033921e9aa9995d43a4f43ff51aef755 (diff) |
Check for multiplication overflow in drm_calloc(). ok oga@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/drm_memory.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c index 44714ca310b..8d999638b19 100644 --- a/sys/dev/pci/drm/drm_memory.c +++ b/sys/dev/pci/drm/drm_memory.c @@ -57,8 +57,10 @@ drm_alloc(size_t size, int area) void * drm_calloc(size_t nmemb, size_t size, int area) { - /* XXX overflow checking */ - return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO); + if (SIZE_MAX / nmemb < size) + return (NULL); + else + return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO); } void * |