Path: csiph.com!au2pb.net!feeder.erje.net!2.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod From: Eric Dumazet Newsgroups: linux.kernel Subject: Re: [v2] ath6kl: Use vmalloc to allocate ar->fw for api1 method Date: Wed, 02 Dec 2015 14:30:01 +0100 Message-ID: References: X-Original-To: Brent Taylor Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=TUpg+6NTjkl3MJ4G96g8pAccQY0aowH8zzkPd8le8Ek=; b=yOQtjlZtxxerGwiNw/v8uBD9kEyGvZBC65BxyYYkLsxmGYAoM1eqpxiUo4JOg2tsOo Nd2wg8QXy8puxrXdpeF/NqSHpggKoZGMF8IuFAYztHHXqi/ZnzuaZp1q0aJz/7F6Y8xy 6fWjmGD7M7cXGevWxmcPXPLwerP9Mj5Bgx4di/9zhvDRgEqXvqu7NVmZDRYLEzTdI93L oArpyiYKV973YEId/6Kc9f9O9UBZASfNPEUe9VEN7NzLKNYV41e5lJ+UOSiFw/pFLFv2 /Tr0/WjWcjAA6mkh7BmV45ZQ1p2S5pCvKF2H8M9CzhgO8TtVbHLnUalvNYwi7ONd4roK C8Iw== X-Received: by 10.98.87.136 with SMTP id i8mr4521769pfj.94.1449062434376; Wed, 02 Dec 2015 05:20:34 -0800 (PST) Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 53 Organization: linux.* mail to news gateway X-Original-Cc: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ath6kl@lists.infradead.org X-Original-Date: Wed, 02 Dec 2015 05:20:33 -0800 X-Original-Message-ID: <1449062433.32764.49.camel@edumazet-glaptop2.roam.corp.google.com> X-Original-References: <1449029898-15209-1-git-send-email-motobud@gmail.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1281777 On Tue, 2015-12-01 at 22:18 -0600, Brent Taylor wrote: > Since commit 8437754c8335 ("ath6kl: Use vmalloc instead of kmalloc for > fw") ar->fw is expected to be pointing to memory allocated by vmalloc. > If the api1 method (via ath6kl_fetch_fw_api1) is used to allocate memory > for ar->fw, then kmemdup is used. This patch checks if the firmware being > loaded is the 'fw' image, then use vmalloc, otherwise use kmalloc. > > Signed-off-by: Brent Taylor > --- > v2: Fix commit message and code formatting (use tab instaed of spaces) > > drivers/net/wireless/ath/ath6kl/init.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c > index 6ae0734..4f16bd8 100644 > --- a/drivers/net/wireless/ath/ath6kl/init.c > +++ b/drivers/net/wireless/ath/ath6kl/init.c > @@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename, > return ret; > > *fw_len = fw_entry->size; > - *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); > + if (&ar->fw == fw) > + *fw = vmalloc(fw_entry->size); > + else > + *fw = kmalloc(fw_entry->size, GFP_KERNEL); > > if (*fw == NULL) > ret = -ENOMEM; > + else > + memcpy(*fw, fw_entry->data, fw_entry->size); > > release_firmware(fw_entry); > This looks very odd. Why not using kvfree() in ath6kl_core_cleanup() ? If you switch to vmalloc() here because the kmemdup() was potentially failing, then the changelog should say it ! Using vmalloc() instead of kmalloc() should be driven by the allocation size, not the legacy code doing the freeing. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/