diff options
author | jkim <jkim@FreeBSD.org> | 2013-08-28 18:13:37 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-08-28 18:13:37 +0000 |
commit | 150b502476c182aeab4bb89205740ef0ecb1cbc8 (patch) | |
tree | ee8763e6c0d7119a6a42c55cec6964b98500b149 /sys/dev/fb | |
parent | 77c4dc92ec8722e52cfa36ba7a5cdf6b4ae3f4d7 (diff) | |
download | FreeBSD-src-150b502476c182aeab4bb89205740ef0ecb1cbc8.zip FreeBSD-src-150b502476c182aeab4bb89205740ef0ecb1cbc8.tar.gz |
Make sure to free stale buffer before allocating new one for safety.
Diffstat (limited to 'sys/dev/fb')
-rw-r--r-- | sys/dev/fb/vesa.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index 6d56193..1fa489c 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -1475,6 +1475,10 @@ vesa_save_state(video_adapter_t *adp, void *p, size_t size) if (vesa_state_buf_size > 0 && size < bsize) return (EINVAL); + if (vesa_vmem_buf != NULL) { + free(vesa_vmem_buf, M_DEVBUF); + vesa_vmem_buf = NULL; + } if (VESA_MODE(adp->va_mode) && adp->va_buffer != 0) { buf = adp->va_buffer; bsize = adp->va_buffer_size; @@ -1486,8 +1490,7 @@ vesa_save_state(video_adapter_t *adp, void *p, size_t size) vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT); if (vesa_vmem_buf != NULL) bcopy((void *)buf, vesa_vmem_buf, bsize); - } else - vesa_vmem_buf = NULL; + } if (vesa_state_buf_size == 0) return ((*prevvidsw->save_state)(adp, p, size)); ((adp_state_t *)p)->sig = V_STATE_SIG; @@ -1524,6 +1527,7 @@ vesa_load_state(video_adapter_t *adp, void *p) bcopy(vesa_vmem_buf, (void *)buf, bsize); } free(vesa_vmem_buf, M_DEVBUF); + vesa_vmem_buf = NULL; } if (((adp_state_t *)p)->sig != V_STATE_SIG) return ((*prevvidsw->load_state)(adp, p)); |