Bug 134355 - [mbuf] comments for m_getm2 inconsistent with behaviour
Summary: [mbuf] comments for m_getm2 inconsistent with behaviour
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Andriy Voskoboinyk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 03:00 UTC by Martin Karsten
Modified: 2021-10-07 20:04 UTC (History)
2 users (show)

See Also:
avos: mfc-stable12?
avos: mfc-stable11?
avos: mfc-stable10?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Karsten 2009-05-08 03:00:08 UTC
It seems to me that the comments describing m_getm2 are inconsistent with the behaviour. The comment states that the function returns the top of the newly allocated chain, but it in fact returns the top of the overall chain.

Fix: 

To return the top of the newly allocated chain, the last statement in line 151 would need to be changed from

  return (m);

to

  return (nm);

and the very last else-clause before that is not needed.
How-To-Repeat: N/A
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-05-08 04:36:00 UTC
State Changed
From-To: open->feedback

To which part of the tree does this apply?
Comment 2 Martin Karsten 2009-05-08 19:46:22 UTC
Sorry, I'm not familiar with the development tree. I've found it in

/usr/src/sys/kern/uipc_mbuf.c

on a 7.2-RELEASE system.

Thanks,
Martin
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2009-05-11 17:45:31 UTC
State Changed
From-To: feedback->open

feedback received.
Comment 4 Mark Linimon 2009-05-11 17:46:21 UTC
----- Forwarded message from Martin Karsten <mkarsten@cs.uwaterloo.ca> -----

From: Martin Karsten <mkarsten@cs.uwaterloo.ca>
To: linimon@FreeBSD.org
CC: freebsd-bugs@FreeBSD.org
Subject: Re: kern/134355: comments for m_getm2 inconsistent with behaviour

Sorry, I'm not familiar with the development tree. I've found it in

/usr/src/sys/kern/uipc_mbuf.c

on a 7.2-RELEASE system.

Thanks,
Martin

linimon@FreeBSD.org wrote:
> Old Synopsis: cooments for m_getm2 inconsistent with behaviour
> New Synopsis: comments for m_getm2 inconsistent with behaviour
> 
> State-Changed-From-To: open->feedback
> State-Changed-By: linimon
> State-Changed-When: Fri May 8 03:36:00 UTC 2009
> State-Changed-Why: 
> To which part of the tree does this apply?
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=134355


----- End forwarded message -----
Comment 5 Volker Werth freebsd_committer freebsd_triage 2009-06-17 21:07:52 UTC
State Changed
From-To: open->analyzed

Martin, 
thank you for your submission. 
In the first place I thought you've found a code bug but while carefully 
analyzing usage of m_getm2(), I haven't been able to to find a sign 
of trouble. I agree current implementation isn't intentional and might 
easily lead into misuse of m_getmw() but the function is rarely used. 
I think the issue can be solved by "fixing" the leading comment by 
something like the following. 

--- uipc_mbuf.c.orig	2009-06-17 22:03:53.000000000 +0200 
+++ uipc_mbuf.c	2009-06-17 22:06:24.000000000 +0200 
@@ -90,8 +90,9 @@ 
* 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 but still return the top of the newly allocated 
- * chain. 
+ * to the existing one but still return the top of the pre-existing 
+ * chain. If no pre-existing mbuf chain is given, we return the top 
+ * of the new allocated mbuf chain. 
*/ 
struct mbuf * 
m_getm2(struct mbuf *m, int len, int how, short type, int flags)
Comment 6 Andre Oppermann freebsd_committer freebsd_triage 2010-08-24 09:24:31 UTC
Responsible Changed
From-To: freebsd-bugs->andre

Take over.
Comment 7 Eitan Adler freebsd_committer freebsd_triage 2018-01-08 04:14:45 UTC
For the following conditions
Product: Base System, Documentation Status: New, Open, In Progress, UNCONFIRMED 
Assignee: Former FreeBSD committer 

Reset to default assignee. Reset status to "Open".
Comment 8 Andriy Voskoboinyk freebsd_committer freebsd_triage 2019-01-27 16:49:27 UTC
Committed in base r343500; will be closed after MFC
Comment 9 Piotr Pawel Stefaniak freebsd_committer freebsd_triage 2021-10-07 20:04:04 UTC
It appears that this has been fixed in all supported releases.