Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2498856imm; Mon, 24 Sep 2018 05:30:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62AskWcjoWNpGfDl9A1GXsSRig5Q9CNa6Y6NfODTfViwEfvBOCCAdoj0y8cSoeelZIcmli+ X-Received: by 2002:a63:ee56:: with SMTP id n22-v6mr9350902pgk.402.1537792244151; Mon, 24 Sep 2018 05:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792244; cv=none; d=google.com; s=arc-20160816; b=iOTJ8JDdh41D9XqSWBuX/ezhW8UXwlcX2smWSCIR6mse0gREvkde3SL8QOVe3iBBS4 K/oYzmlpD6oFActFfGDp+oUmNEYSI6PkKvg7E4FImKiuU67CdIPVs+q04wrxvXHZdNdF btjM1kj4q4ThEjB++wSGNAPQvv1F16XLL1zwXgoj0t9R4BOij8Q8T37RZnJ041GzqgP6 oMF7RdgjR6TdCtL/nzSRdoT46R/KipAr9QkNhFCiAt2/m7xJg+DM77is1x7WpmH8eEIH oZia1G1rHM8Jy48evkvpP8LQFK6G9jOOLmAfHOyMXFbBEv59XeBx+9Dvou5NBDxwwAB3 J7dA== 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; bh=UOe6OkKOYWnYrntrzzObIN/QWJiVBFvqwpSvs3R23zA=; b=Fne0hGOKXVp+L5zdl4yosT5WtlL+juKZ5li7YjA56EiCcZYueDliWX7nhI6iCKDmqD uJkyxKCZwOClHvGH2fp16GwEoXUACI8mtNUrwOaqGtQj4/DaUXAgxUiz1IHSVPPC4Upg VUh/Np8w6QmPEehG5jBIhimiGVZBCCTfRWe6y+7i7Iv2loCLrSs47s+R6lT4P2WW6IsF BQN+6EHZWg4+Zw5KrMEywkU9dNXiTUf56ElWXLbYiVADik7wgUwJghoxDtqtWqmvjXHv Au1UzcRLxVQxsS5eJ6z2NnL54vTghd2Lx6yHoMMHC3pQd0ulbN36Jp1mnW0nVGwq/4HY wkJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bd1-v6si36090386plb.156.2018.09.24.05.30.28; Mon, 24 Sep 2018 05:30:44 -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; 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 S2387685AbeIXSbG (ORCPT + 99 others); Mon, 24 Sep 2018 14:31:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57568 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732800AbeIXSbF (ORCPT ); Mon, 24 Sep 2018 14:31:05 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D8E7E1018; Mon, 24 Sep 2018 12:29:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huy Nguyen , Saeed Mahameed Subject: [PATCH 4.18 008/235] net/mlx5: Check for error in mlx5_attach_interface Date: Mon, 24 Sep 2018 13:49:54 +0200 Message-Id: <20180924113105.139503955@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Huy Nguyen [ Upstream commit 47bc94b82291e007da61ee1b3d18c77871f3e158 ] Currently, mlx5_attach_interface does not check for error after calling intf->attach or intf->add. When these two calls fails, the client is not initialized and will cause issues such as kernel panic on invalid address in the teardown path (mlx5_detach_interface) Fixes: 737a234bb638 ("net/mlx5: Introduce attach/detach to interface API") Signed-off-by: Huy Nguyen Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -132,11 +132,11 @@ void mlx5_add_device(struct mlx5_interfa delayed_event_start(priv); dev_ctx->context = intf->add(dev); - set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); - if (intf->attach) - set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); - if (dev_ctx->context) { + set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); + if (intf->attach) + set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); + spin_lock_irq(&priv->ctx_lock); list_add_tail(&dev_ctx->list, &priv->ctx_list); @@ -211,12 +211,17 @@ static void mlx5_attach_interface(struct if (intf->attach) { if (test_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state)) goto out; - intf->attach(dev, dev_ctx->context); + if (intf->attach(dev, dev_ctx->context)) + goto out; + set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); } else { if (test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state)) goto out; dev_ctx->context = intf->add(dev); + if (!dev_ctx->context) + goto out; + set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); }