Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Sep 2011 07:33:04 +0000 (UTC)
From:      Stanislav Sedov <stas@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r225780 - stable/8/sys/dev/smc
Message-ID:  <201109270733.p8R7X4wD010764@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: stas
Date: Tue Sep 27 07:33:04 2011
New Revision: 225780
URL: http://svn.freebsd.org/changeset/base/225780

Log:
  - MFC r225354:
    - Fix NULL pointer dereference when a packet of uneven size is being
    transmitted.

Modified:
  stable/8/sys/dev/smc/if_smc.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/smc/if_smc.c
==============================================================================
--- stable/8/sys/dev/smc/if_smc.c	Tue Sep 27 07:19:01 2011	(r225779)
+++ stable/8/sys/dev/smc/if_smc.c	Tue Sep 27 07:33:04 2011	(r225780)
@@ -538,6 +538,7 @@ smc_task_tx(void *context, int pending)
 	struct smc_softc	*sc;
 	struct mbuf		*m, *m0;
 	u_int			packet, len;
+	int			last_len;
 	uint8_t			*data;
 
 	(void)pending;
@@ -590,16 +591,18 @@ smc_task_tx(void *context, int pending)
 	 * Push the data out to the device.
 	 */
 	data = NULL;
+	last_len = 0;
 	for (; m != NULL; m = m->m_next) {
 		data = mtod(m, uint8_t *);
 		smc_write_multi_2(sc, DATA0, (uint16_t *)data, m->m_len / 2);
+		last_len = m->m_len;
 	}
 
 	/*
 	 * Push out the control byte and and the odd byte if needed.
 	 */
 	if ((len & 1) != 0 && data != NULL)
-		smc_write_2(sc, DATA0, (CTRL_ODD << 8) | data[m->m_len - 1]);
+		smc_write_2(sc, DATA0, (CTRL_ODD << 8) | data[last_len - 1]);
 	else
 		smc_write_2(sc, DATA0, 0);
 



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