From patchwork Sat Dec 24 16:52:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 9488083 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0446B601D3 for ; Sat, 24 Dec 2016 16:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9F222094D for ; Sat, 24 Dec 2016 16:57:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE9F620952; Sat, 24 Dec 2016 16:57:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59B4209CF for ; Sat, 24 Dec 2016 16:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755058AbcLXQ5Z (ORCPT ); Sat, 24 Dec 2016 11:57:25 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33327 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754122AbcLXQ5T (ORCPT ); Sat, 24 Dec 2016 11:57:19 -0500 Received: by mail-wm0-f68.google.com with SMTP id u144so46956286wmu.0; Sat, 24 Dec 2016 08:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vR5Edik4r+jJZ97BDjfI+NdOwqJ8ha/0nhzqAL+N1lg=; b=G6qP9G5MUPefB//tJLzigf7PJib8Ees62U4LM4y8dSGLi5sXC5qVSfG2qtJPcAyctK TcbKVRJlqjIBGqR8qCUQNipvJAEillqwx0/E0exK7YHtK1yEc8Bo3J8qn0KX1F1up5au YHF4y+UdQtMWLkV5Fcd+EU5uufNQs9UkZg6JmTQGZWUoril0NNhTqxAn8a91F4yXl3gW FuwBmytGIMjd7NUNLLAoaa1OKdT3YWClbeklOfI14BDOEu6pjPB17Z+7ewJB49PB6g4t fgM0hJEPMuTTkfPGbyEZZsgsucqDfK/xOx5FKUxuUrEN7Mg6OKPqHmN80YilYq3Zyay6 NRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vR5Edik4r+jJZ97BDjfI+NdOwqJ8ha/0nhzqAL+N1lg=; b=CBW2Td5DdFL6GIVuIuRqFaWq0r6skuWFi6t0/LfLpQXab9pl+G75p3LOwfg/D8L+nC s/41q7c2MoP6O9+9dIllgwIgw6gxH9VE4xTWwV/569t+aLYc97TAKm9ITD9+BuXydcMr DHov8LgwaEmqtgyhQ72bQsy8FcBdmaAZYOU6Zqw7rxr8c+sJHGCg3SyKWsgaZfKIaKen lB/Itexin7xu+lq+Vli45Gzltoe0RyzdctxBui+yEYTBKnb3Vw5BZpCxSJ/56D9Pc87D 4d5FZxaRX2j2deIg9M53khRoDuWE2rwRt58ZGTQsajg9XNlC1Y1hX1cglpkvffEOKuxe 5VKQ== X-Gm-Message-State: AIkVDXKq2ZxqyW3N4B5kl4D5UKYulUD6/5n59WgMzrxzOcGLHOMEHiJzFwFL/4HSUwS1jg== X-Received: by 10.28.64.136 with SMTP id n130mr14591674wma.45.1482598449361; Sat, 24 Dec 2016 08:54:09 -0800 (PST) Received: from localhost.localdomain (ip-88-212-34-237.antik.sk. [88.212.34.237]) by smtp.gmail.com with ESMTPSA id b15sm42736940wma.5.2016.12.24.08.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Dec 2016 08:54:08 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Ming Lei , "Luis R. Rodriguez" , Greg Kroah-Hartman , Kalle Valo , David Gnedt , Michal Kazior , Daniel Wagner , Tony Lindgren , Sebastian Reichel , Pavel Machek , Ivaylo Dimitrov , Aaro Koskinen , Grazvydas Ignotas Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 3/6] wl1251: Update wl->nvs_len after wl->nvs is valid Date: Sat, 24 Dec 2016 17:52:58 +0100 Message-Id: <1482598381-16513-4-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> References: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case kmemdup fails thne wl->nvs_len will contains invalid non-zero size. This patch fixes it. Signed-off-by: Pali Rohár Acked-by: Pavel Machek --- drivers/net/wireless/ti/wl1251/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c index 24f8866..8971b64 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c @@ -124,8 +124,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl) goto out; } - wl->nvs_len = fw->size; - wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL); + wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); if (!wl->nvs) { wl1251_error("could not allocate memory for the nvs file"); @@ -133,6 +132,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl) goto out; } + wl->nvs_len = fw->size; + ret = 0; out: