Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1970395ima; Thu, 25 Oct 2018 07:44:54 -0700 (PDT) X-Google-Smtp-Source: AJdET5f+f9VB3iWSjrd4dGEQ/R228w0XNuTwVCnWWa8Smk4Em/NKqdq33hw9BsnuNAEAnmZgxCJa X-Received: by 2002:a17:902:8bc6:: with SMTP id r6-v6mr1824874plo.0.1540478694491; Thu, 25 Oct 2018 07:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478694; cv=none; d=google.com; s=arc-20160816; b=fsttavNpWO4vDWNQxFWVaf3tPK0wJZmUFV6/5A2SmGOjTcywl/vkKGJygUE0JVyiKI 5HOuqqzxGu/jvjXKfHJycnMA8GICs2juQvJmbZU5Gp4Sdy9hgF/qTdVYnnhXoqKqVmRN 0Rk/7uwoLiybwM4tXg03nJC2K7A7Nyc1bAmpdb33fc+j2MZljDDRJBBEy7XbNb4BeGey KN/E/xdH3Z8GKZVR/B0hiNnmHSk27BCvk8qbfHHHipyFwkqKOomAO4nnKBMpSOKJyozw Mmu0VXKmA22zenEOT9eOCv0yetl59rP0GAQLXETWABuUZhSj/so1splEF8gLw+eooc2Q IIJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=quVUW9Mi1haTIXQ3PRxNmxm4UT5yrQbuhJwmSqVds7s=; b=u2LACRDdZvsgF9mE5/4D9HUMUGQVSwHpKbr/D8fgkRMPdR4sTTKhTc7OitoQ64XmOH SXANZk1vqovZlgghSkT38mAnZ3L/i9AnQzQL2JoaKWnPD95pUosJhIJAO5roixt61RPG TA8H8+MTg/25IpGBcWN2w2VFMOwV5PqPBUOemkauk3fWd4D3e6KEV2sR0G6r6qxldTDP kTvDAosAvpZX3n4H1Dh7746imJ1u+I4YWCTPPYz+Pj23nYtgz/px0+rmBbJjZe5SAFBF Aw74CGzRxr7ZCI5Lz6weqBqRQ4nKkWzAKys9IYyW8UJL5fcPbmTIQmsQpOiwI5BbF0OQ bYtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=psvWZ1lj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w64-v6si8317972pfb.247.2018.10.25.07.44.15; Thu, 25 Oct 2018 07:44:54 -0700 (PDT) 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=psvWZ1lj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728717AbeJYWrx (ORCPT + 99 others); Thu, 25 Oct 2018 18:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbeJYWrw (ORCPT ); Thu, 25 Oct 2018 18:47:52 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 272132085A; Thu, 25 Oct 2018 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476896; bh=fpvHzjiypylW1HR/O/IGKN+C3WoLRhzi+u8tB7bTkyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=psvWZ1ljUWQWCuECnJUjbv+XcFByrBc7pFWzaSUIL79IM2B0X0GfK2Os+wGm3fSCC kiq52r1Afi8rT92uSBXxxt2Yaun/PWjoMswuCutDaiOpwpzVqlgebVVK2d4WK2FsOf 9oNgLuAVrjMtp06LP4eEMsGYiHbEgZ0u/B5Ls1Ew= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Moshe Shemesh , kernel-team@fb.com, Saeed Mahameed , Sasha Levin Subject: [PATCH AUTOSEL 4.9 20/98] net/mlx5: Fix command completion after timeout access invalid structure Date: Thu, 25 Oct 2018 10:13:05 -0400 Message-Id: <20181025141423.213774-20-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Moshe Shemesh [ Upstream commit 061870800efb4e3d1ad4082a2569363629bdfcfc ] Completion on timeout should not free the driver command entry structure as it will need to access it again once real completion event from FW will occur. Fixes: 73dd3a4839c1 ('net/mlx5: Avoid using pending command interface slots') Signed-off-by: Moshe Shemesh Cc: kernel-team@fb.com Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 9680c8805178..1d5263c46eee 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -965,7 +965,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, err = wait_func(dev, ent); if (err == -ETIMEDOUT) - goto out_free; + goto out; ds = ent->ts2 - ent->ts1; op = MLX5_GET(mbox_in, in->first.data, opcode); @@ -1428,6 +1428,7 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced) mlx5_core_err(dev, "Command completion arrived after timeout (entry idx = %d).\n", ent->idx); free_ent(cmd, ent->idx); + free_cmd(ent); } continue; } @@ -1486,7 +1487,8 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced) free_msg(dev, ent->in); err = err ? err : ent->status; - free_cmd(ent); + if (!forced) + free_cmd(ent); callback(err, context); } else { complete(&ent->done); -- 2.17.1