summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_mbuf.c
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2003-02-14 16:50:13 +0000
committerbmilekic <bmilekic@FreeBSD.org>2003-02-14 16:50:13 +0000
commit49e9cba72ec1f86896a57d3e2a24fb78161903b1 (patch)
treefab42c2a7fc0ad9040c95c05a577d58f9b7e5883 /sys/kern/subr_mbuf.c
parent0e0470bb8d3ddedfba1714e34f6f0b687b6d653e (diff)
downloadFreeBSD-src-49e9cba72ec1f86896a57d3e2a24fb78161903b1.zip
FreeBSD-src-49e9cba72ec1f86896a57d3e2a24fb78161903b1.tar.gz
Make m_getm() always return the top of the newly allocated chain, as
opposed to returning the top of the old chain when there was one and the top of the newly allocated chain if there was no old chain. Actually, it should be noted that prior to this fix, although the comment above m_getm() advertised that m_getm() would return the top of the old chain (if an old chain was being passed in) it actually [wrongly] was returning the tail mbuf in the old chain instead. This is a bug but since the one use of m_getm() in the tree luckily did not depend on the behavior, it happened to work out without notice. Harti Brandt pointed out that the advertised behavior was actually not the real behavior and so this change makes m_getm() ALWAYS return the newly allocated chain (and fixes the comment). This is less confusing and is the best course of action as then the caller is always able to have both a reference to the top of the original chain (because it's passing it in in the call) and a reference to the newly attached chain. Although the API is slightly modified, I don't think that any third-party code uses m_getm() and if it does, it surely can't be working properly because the old behavior was bogus. API bug pointed out by: Harti Brandt <brandt@fokus.fraunhofer.de>
Diffstat (limited to 'sys/kern/subr_mbuf.c')
-rw-r--r--sys/kern/subr_mbuf.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c
index 7f3f960..97944ec 100644
--- a/sys/kern/subr_mbuf.c
+++ b/sys/kern/subr_mbuf.c
@@ -1147,7 +1147,7 @@ m_get(int how, short type)
* Allocate a given length worth of mbufs and/or clusters (whatever fits
* best) and return a pointer to the top of the allocated chain. If an
* existing mbuf chain is provided, then we will append the new chain
- * to the existing one and return the top of the provided (existing)
+ * to the existing one but still return the top of the newly allocated
* chain. NULL is returned on failure, in which case the [optional]
* provided chain is left untouched, and any memory already allocated
* is freed.
@@ -1235,9 +1235,7 @@ m_getm(struct mbuf *m, int len, int how, short type)
if (mtail != NULL)
mtail->m_next = top;
- else
- mtail = top;
- return mtail;
+ return top;
failed:
if (top != NULL)
m_freem(top);
OpenPOWER on IntegriCloud