Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Aug 2013 18:13:38 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r254998 - head/sys/dev/fb
Message-ID:  <201308281813.r7SIDcpp091635@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Wed Aug 28 18:13:37 2013
New Revision: 254998
URL: http://svnweb.freebsd.org/changeset/base/254998

Log:
  Make sure to free stale buffer before allocating new one for safety.

Modified:
  head/sys/dev/fb/vesa.c

Modified: head/sys/dev/fb/vesa.c
==============================================================================
--- head/sys/dev/fb/vesa.c	Wed Aug 28 17:58:30 2013	(r254997)
+++ head/sys/dev/fb/vesa.c	Wed Aug 28 18:13:37 2013	(r254998)
@@ -1475,6 +1475,10 @@ vesa_save_state(video_adapter_t *adp, vo
 	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, vo
 		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, vo
 				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));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308281813.r7SIDcpp091635>