Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17926148ybl; Thu, 2 Jan 2020 14:58:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy0SmF1jM9i3KsSdnnbSZ4pVg6XqOsE8iWw2wssBrNITEP1DzKQLyzdaOsdQul0S3pdAamO X-Received: by 2002:a05:6830:128e:: with SMTP id z14mr91578685otp.184.1578005880064; Thu, 02 Jan 2020 14:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005880; cv=none; d=google.com; s=arc-20160816; b=Yrx/GY8C0ws3YvqoCLkVE4Gg3CxL1mlhXAAPLwvuJpSLSbC04cqnXL7++pj9v4YSZG keKVFZyRKkMvbGYlOejvjEqFjp3vHF3difWF6OGSYJhw6DZ/wAvHfiSb47Zddq4dFiCU X1dC/i0NHnRnSe2m8AC1ELniRVn2v40Xy8VG5qpLTLfI6JEtz+jy7GeGgeVfcyQKFFMg XvAqhTp519LxYd2IjTqJecfA+z2K71x6cpqSYXKhvGlraDvWClJ3T3yWxvTrhE9m2k2F wieCGKtDKdRHnNJC9Jxava/38rjD1VCwzPlUY+75DMXUoaFInbG0XaBQZ+OiiP+M/Rrc aNJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/s20yu06+kXtNToiKZeRRbmJf4VED3lTYWUPd3fjOUg=; b=XBqLUKzq2Bt2AC8pqoZRI/0xZcZTOlszveix9hPQ+vV8AHI1ZvGYDvFOk3701BLsaL gHqlAv0VFS3OZcVArMDsFZLu871ZssjFo5CVFjqmg83jiEV17WeVW/MW7wiDNYMYXFRK BPd7XxQFoaVeCSnT4SZF1J5I781cn4cQqTBDMh+a9Gs15pNgttYItCt0BlK2YCp3vL/P FIMwcI+jcP/61GT2AVxrGQnjC8I4TDY/szCKdUHN46Pqkedtikiv+KXNzwAGP1Z9nWyk XzzpZ/G3+hYwp2tnsdZPDdpXiB+I2zjGvY1GZXT94sKSKudBD6G6I30VgX32xslkyEFC Jt2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E0eIb4Qb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si27784677otq.92.2020.01.02.14.57.48; Thu, 02 Jan 2020 14:58:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E0eIb4Qb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbgABWR4 (ORCPT + 99 others); Thu, 2 Jan 2020 17:17:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:60838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbgABWRy (ORCPT ); Thu, 2 Jan 2020 17:17:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4753921582; Thu, 2 Jan 2020 22:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003473; bh=BLy635XSDMjIwwCgJN1nQvdDhCKHwCkK84/xj2G/bII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0eIb4Qb5A8jCdrEbfBe2YIpsBJo7JgLHNTOYMbmAGT0eA8dTOvoRlVKkgh9TVtZc Nwk9EomDUznPZDnfHfSGU5g31f4Yl1wtaJDUwVSloljM4Wg01Nu/eburRFsngImJ3k zUxSXsexCf1Z+Z1Bvkab0PNAxXwF/exp28X9DxeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladyslav Tarasiuk , Aya Levin , Leon Romanovsky , Ido Schimmel , "David S. Miller" Subject: [PATCH 5.4 149/191] net/mlxfw: Fix out-of-memory error in mfa2 flash burning Date: Thu, 2 Jan 2020 23:07:11 +0100 Message-Id: <20200102215845.457450510@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladyslav Tarasiuk [ Upstream commit a5bcd72e054aabb93ddc51ed8cde36a5bfc50271 ] The burning process requires to perform internal allocations of large chunks of memory. This memory doesn't need to be contiguous and can be safely allocated by vzalloc() instead of kzalloc(). This patch changes such allocation to avoid possible out-of-memory failure. Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process") Signed-off-by: Vladyslav Tarasiuk Reviewed-by: Aya Levin Signed-off-by: Leon Romanovsky Tested-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c +++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "mlxfw_mfa2.h" #include "mlxfw_mfa2_file.h" @@ -548,7 +549,7 @@ mlxfw_mfa2_file_component_get(const stru comp_size = be32_to_cpu(comp->size); comp_buf_size = comp_size + mlxfw_mfa2_comp_magic_len; - comp_data = kmalloc(sizeof(*comp_data) + comp_buf_size, GFP_KERNEL); + comp_data = vzalloc(sizeof(*comp_data) + comp_buf_size); if (!comp_data) return ERR_PTR(-ENOMEM); comp_data->comp.data_size = comp_size; @@ -570,7 +571,7 @@ mlxfw_mfa2_file_component_get(const stru comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len; return &comp_data->comp; err_out: - kfree(comp_data); + vfree(comp_data); return ERR_PTR(err); } @@ -579,7 +580,7 @@ void mlxfw_mfa2_file_component_put(struc const struct mlxfw_mfa2_comp_data *comp_data; comp_data = container_of(comp, struct mlxfw_mfa2_comp_data, comp); - kfree(comp_data); + vfree(comp_data); } void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file)