Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11794530pjo; Thu, 2 Jan 2020 14:24:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxCpAtlSNZuBm7a/GgvAp6P9g//47WsRMsvssN18vUlmAnuE3zsEW93Dj+7CD6SO9GB8TPa X-Received: by 2002:a9d:5888:: with SMTP id x8mr90631124otg.361.1578003842904; Thu, 02 Jan 2020 14:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003842; cv=none; d=google.com; s=arc-20160816; b=ucw5Sm0SCGIaR1FfPBUN0ibDHI44SZrmVYLeZdtKFufS6OG46bqOPFAWH/mJd6AMXt eV9QqezTHDMsq54tiA+nenoX3QWm8+JtILkMJE4WBpKU6PkHOBWgb4D6j/VU+FPo4mVC SqJKXlhAAefyixnZvETjFW9o2l9mhH6562GII4hP6LdW+XOWLBdXeUhmjH84+Dz+OyD1 0PPie5Zpbmh8OBMRZ9SzRCY3OeAfx67cAJZBwDsqDQWM0ZQp/wOcj0E8dtTnTcZMFP/j fnJsf6jnIrLkqVcATV3QXgkoSXSL1eeSxgTh3FlA9n5n2iZPmFZSXZf+mFIsJWVbcSZy kivQ== 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=FTHHkXRce63Zm1LQa4DZKN0V4ahEi5vAWGHtKFBubCE=; b=dAS7sOttfl/6EhhM2A3EgzzAkbAScD+sPKYW+N+O2Fn/qVRXRXojlf/LypwMWpnPV7 DBkMmwPO76+9qjsai1g+JS+aK/ImK7FqLo8AbWqTumHTWvqgU26Z3pwdl8yAtr1vQl6P y45LKTR7LeIbQv9olKHET0NXHe4rqUKzs4eJsH9xWMq3NOYThtWE+JpDo2NZA6sUiUuc 7G6P3J9oJHrq+9nGzKQor9DWTfcfcn2EeDYuMBZw8DohoE8aV3zuFuQ2r3NMHNYNuWPr fkKAO2+FCu3oYA29Bvr3q38N+wd27hrw1ZLl2dNCClfMSmhDgi//Pc8A002GZKpNg3ML AWyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v77NXwYN; 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 j71si26997283oib.213.2020.01.02.14.23.51; Thu, 02 Jan 2020 14:24:02 -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=v77NXwYN; 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 S1727533AbgABWWN (ORCPT + 99 others); Thu, 2 Jan 2020 17:22:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:42342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728730AbgABWWK (ORCPT ); Thu, 2 Jan 2020 17:22:10 -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 0E765222C3; Thu, 2 Jan 2020 22:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003730; bh=JB+DYKIwsZBH1KvlL773j+Eii/K1XDeuwoVDewlsQYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v77NXwYNQLcZWK58gb4MCKJZ8izLheiid14b1BjO6+U2ApQvgb5dziAzU85Ld5SW2 /sdn+F9Lzim3gGxgV1ef0oqGMNhJGdjUjVpoJo2CL8+jqLRGwA3/DxEfZWFLze9zpN VV6clErBp+uf1RY/XZ/iSGr+istRPBBUJsch/Zh8= 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 4.19 091/114] net/mlxfw: Fix out-of-memory error in mfa2 flash burning Date: Thu, 2 Jan 2020 23:07:43 +0100 Message-Id: <20200102220038.346666896@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@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 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "mlxfw_mfa2.h" #include "mlxfw_mfa2_file.h" @@ -579,7 +580,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; @@ -601,7 +602,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); } @@ -610,7 +611,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)