From owner-svn-src-head@FreeBSD.ORG Fri Sep 2 20:35:22 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B77B21065674; Fri, 2 Sep 2011 20:35:22 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A6A7F8FC1C; Fri, 2 Sep 2011 20:35:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p82KZMbo015061; Fri, 2 Sep 2011 20:35:22 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p82KZMJr015059; Fri, 2 Sep 2011 20:35:22 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <201109022035.p82KZMJr015059@svn.freebsd.org> From: Stanislav Sedov Date: Fri, 2 Sep 2011 20:35:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225354 - head/sys/dev/smc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 20:35:22 -0000 Author: stas Date: Fri Sep 2 20:35:22 2011 New Revision: 225354 URL: http://svn.freebsd.org/changeset/base/225354 Log: - Fix NULL pointer dereference when a packet of uneven size is being transmitted. Approved by: re (kib) MFC after: 3 days Modified: head/sys/dev/smc/if_smc.c Modified: head/sys/dev/smc/if_smc.c ============================================================================== --- head/sys/dev/smc/if_smc.c Fri Sep 2 19:29:37 2011 (r225353) +++ head/sys/dev/smc/if_smc.c Fri Sep 2 20:35:22 2011 (r225354) @@ -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);