From patchwork Thu Nov 9 23:38:23 2017 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: 10052101 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 3193E6032D for ; Thu, 9 Nov 2017 23:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A092B1D1 for ; Thu, 9 Nov 2017 23:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 197052B1D5; Thu, 9 Nov 2017 23:41:02 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable 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 B450E2B1D9 for ; Thu, 9 Nov 2017 23:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755297AbdKIXiv (ORCPT ); Thu, 9 Nov 2017 18:38:51 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52417 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755248AbdKIXis (ORCPT ); Thu, 9 Nov 2017 18:38:48 -0500 Received: by mail-wm0-f67.google.com with SMTP id t139so20953664wmt.1; Thu, 09 Nov 2017 15:38:48 -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=E1WcDDNHlAHMMv6ajY2myhfqN0FAIae37lsRpC9mn64=; b=uw54oEVjJwDm8eUYZlJzhOdnxwR+e7CK3rtA//JYeElQ4MGRGpXITBOpW+4BmlQgEX VVff6YnnVIdiSEV/sKV78Yeq1tTiHqMXEzxfSAEnvJ5aFLJbekzEHiNcbmdpzui7eMho F+AOJa2iII5bZxGgBfUOOPK/mXr6EcVsq4qEm06p9T4DsjqEby8WEgcCpNvdpaDmQKp/ gk/x5LiW+Qei+EezVrQB6TaQEi1mM1oWlyEGC1hx+hndcwleC+ZRmN7ZkeT7GlyGboou m6piEHTe2o5KRwTQw5SnuNksWW2J2BRsKBYJc+4nLD/N3PYWxGsiaEFsduIK5LjiIfCJ tHlQ== 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=E1WcDDNHlAHMMv6ajY2myhfqN0FAIae37lsRpC9mn64=; b=LN9yIyFGpkt6X89b+ZT3vu2zQ4z/aNK54OSxjo6jFFkPz5qgGOOMRyrwGP092It6LB ny7PM54JY2NxpANsTyssgie+tUJjVGyhdrr4Sf/e3hU2JkDQ3Owtdun8gm/5hbhJe3LI 66E51d2Snad1E9dEYmWvB/YZys+kI/Pniiac8uVFiv+cBmzRC7GiI582w4mSWl+/h3zA nWN9enpmtKHrjxgGZ/sH1690jYPAKVlm7tBDtufMyrQyYdfGhDcKSvw6X/q4BKts3bZu 8TEuRvjSgCdJ0udVa5lt+BNVJUkL8zs9zhoW8GW10esQyMqrJhng5znbhcMeHVBTeQO1 UkRg== X-Gm-Message-State: AJaThX6G12SzcVXElWP94C1XLyYsOSfF+ky54+/GJIDLocagWfVqy500 2xKtuQv1cMLlkC0P88pT5r4= X-Google-Smtp-Source: ABhQp+TBckoQ1pnGKmykWHY04Zs9C+sWbANAjcLFP0glaS2n8j8h67hSYqQVaB1hHD3oj8g4ud1DFg== X-Received: by 10.28.249.26 with SMTP id x26mr1133103wmh.36.1510270727403; Thu, 09 Nov 2017 15:38:47 -0800 (PST) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id 55sm9578181wrw.60.2017.11.09.15.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 15:38:46 -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 v2 1/6] wl1251: Update wl->nvs_len after wl->nvs is valid Date: Fri, 10 Nov 2017 00:38:23 +0100 Message-Id: <1510270708-14377-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1510270708-14377-1-git-send-email-pali.rohar@gmail.com> References: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> <1510270708-14377-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 If kmemdup fails, then wl->nvs_len will contain invalid non-zero size. 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 9915d83..8929bb3 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c @@ -122,8 +122,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"); @@ -131,6 +130,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl) goto out; } + wl->nvs_len = fw->size; + ret = 0; out: