From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754187AbbIIQAh (ORCPT ); Wed, 9 Sep 2015 12:00:37 -0400 Received: from smtprelay0033.hostedemail.com ([216.40.44.33]:54446 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752988AbbIIQAf (ORCPT ); Wed, 9 Sep 2015 12:00:35 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3871:3872:4321:5007:6261:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12517:12519:12740:13069:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: self59_3ef9f7804ea61 X-Filterd-Recvd-Size: 1759 Message-ID: <1441814431.17219.46.camel@perches.com> Subject: Re: [PATCH 3/4] net: mv643xx_eth: use kzalloc From: Joe Perches To: Rasmus Villemoes Cc: Sebastian Hesselbarth , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 09 Sep 2015 09:00:31 -0700 In-Reply-To: <1441787886-7214-4-git-send-email-linux@rasmusvillemoes.dk> References: <1441787886-7214-1-git-send-email-linux@rasmusvillemoes.dk> <1441787886-7214-4-git-send-email-linux@rasmusvillemoes.dk> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2015-09-09 at 10:38 +0200, Rasmus Villemoes wrote: > The double memset is a little ugly; using kzalloc avoids it altogether. [] > diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c [] > @@ -1859,14 +1859,11 @@ oom: > return; > } > > - mc_spec = kmalloc(0x200, GFP_ATOMIC); > + mc_spec = kzalloc(0x200, GFP_ATOMIC); > if (mc_spec == NULL) > goto oom; > mc_other = mc_spec + (0x100 >> 2); This sure looks wrong as it sets a pointer to unallocated memory. > - memset(mc_spec, 0, 0x100); > - memset(mc_other, 0, 0x100); So this does a memset of random memory. for (i = 0; i < 0x100; i += 4) { wrl(mp, SPECIAL_MCAST_TABLE(mp->port_num) + i, mc_spec[i >> 2]); wrl(mp, OTHER_MCAST_TABLE(mp->port_num) + i, mc_other[i >> 2]); }