Fix drm_realloc when you're reallocing into something smaller.
parent
bffbb497e2
commit
b460aeec3e
|
@ -69,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
|
||||||
if (pt == NULL)
|
if (pt == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (oldpt && oldsize) {
|
if (oldpt && oldsize) {
|
||||||
memcpy(pt, oldpt, oldsize);
|
memcpy(pt, oldpt, DRM_MIN(oldsize,size));
|
||||||
free(oldpt, M_DRM);
|
free(oldpt, M_DRM);
|
||||||
}
|
}
|
||||||
return pt;
|
return pt;
|
||||||
|
|
|
@ -183,7 +183,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
|
||||||
if (!(pt = kmalloc(size, GFP_KERNEL)))
|
if (!(pt = kmalloc(size, GFP_KERNEL)))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (oldpt && oldsize) {
|
if (oldpt && oldsize) {
|
||||||
memcpy(pt, oldpt, oldsize);
|
memcpy(pt, oldpt, DRM_MIN(oldsize,size));
|
||||||
kfree(oldpt);
|
kfree(oldpt);
|
||||||
}
|
}
|
||||||
return pt;
|
return pt;
|
||||||
|
|
Loading…
Reference in New Issue