the two calls to drm_calloc() that had nmemb and size the wrong way
around.
return 0;
}
if (info->rects == NULL) {
- info->rects = drm_calloc(sizeof(*info->rects),
- update->num, DRM_MEM_DRAWABLE);
+ info->rects = drm_calloc(update->num,
+ sizeof(*info->rects), DRM_MEM_DRAWABLE);
if (info->rects == NULL) {
DRM_SPINUNLOCK(&dev->drw_lock);
return ENOMEM;
void *
drm_calloc(size_t nmemb, size_t size, int area)
{
- if (SIZE_MAX / nmemb < size)
+ if (nmemb == 0 || SIZE_MAX / nmemb < size)
return (NULL);
else
return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO);
if (dsd == NULL)
return (NULL);
- dsd->sg_segs = drm_calloc(sizeof(*dsd->sg_segs), pages,
+ dsd->sg_segs = drm_calloc(pages, sizeof(*dsd->sg_segs),
DRM_MEM_SGLISTS);
if (dsd->sg_segs == NULL)
goto dsdfree;