diff options
Diffstat (limited to 'net/sctp/ssnmap.c')
| -rw-r--r-- | net/sctp/ssnmap.c | 42 | 
1 files changed, 17 insertions, 25 deletions
diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c index 442ad4ed631..b9c8521c1a9 100644 --- a/net/sctp/ssnmap.c +++ b/net/sctp/ssnmap.c @@ -18,22 +18,15 @@   * See the GNU General Public License for more details.   *   * You should have received a copy of the GNU General Public License - * along with GNU CC; see the file COPYING.  If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU CC; see the file COPYING.  If not, see + * <http://www.gnu.org/licenses/>.   *   * Please send any bug reports or fixes you make to the   * email address(es): - *    lksctp developers <lksctp-developers@lists.sourceforge.net> - * - * Or submit a bug report through the following website: - *    http://www.sf.net/projects/lksctp + *    lksctp developers <linux-sctp@vger.kernel.org>   *   * Written or modified by:   *    Jon Grimm             <jgrimm@us.ibm.com> - * - * Any bugs reported given to us we will try to fix... any fixes shared will - * be incorporated into the next SCTP release.   */  #include <linux/types.h> @@ -41,8 +34,6 @@  #include <net/sctp/sctp.h>  #include <net/sctp/sm.h> -#define MAX_KMALLOC_SIZE	131072 -  static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,  					    __u16 out); @@ -65,7 +56,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,  	int size;  	size = sctp_ssnmap_size(in, out); -	if (size <= MAX_KMALLOC_SIZE) +	if (size <= KMALLOC_MAX_SIZE)  		retval = kmalloc(size, gfp);  	else  		retval = (struct sctp_ssnmap *) @@ -76,13 +67,12 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,  	if (!sctp_ssnmap_init(retval, in, out))  		goto fail_map; -	retval->malloced = 1;  	SCTP_DBG_OBJCNT_INC(ssnmap);  	return retval;  fail_map: -	if (size <= MAX_KMALLOC_SIZE) +	if (size <= KMALLOC_MAX_SIZE)  		kfree(retval);  	else  		free_pages((unsigned long)retval, get_order(size)); @@ -120,14 +110,16 @@ void sctp_ssnmap_clear(struct sctp_ssnmap *map)  /* Dispose of a ssnmap.  */  void sctp_ssnmap_free(struct sctp_ssnmap *map)  { -	if (map && map->malloced) { -		int size; - -		size = sctp_ssnmap_size(map->in.len, map->out.len); -		if (size <= MAX_KMALLOC_SIZE) -			kfree(map); -		else -			free_pages((unsigned long)map, get_order(size)); -		SCTP_DBG_OBJCNT_DEC(ssnmap); -	} +	int size; + +	if (unlikely(!map)) +		return; + +	size = sctp_ssnmap_size(map->in.len, map->out.len); +	if (size <= KMALLOC_MAX_SIZE) +		kfree(map); +	else +		free_pages((unsigned long)map, get_order(size)); + +	SCTP_DBG_OBJCNT_DEC(ssnmap);  }  | 
