Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1939000ima; Thu, 25 Oct 2018 07:18:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5feK1KnikukNcx0Ii8yG7eXuAxKgNtL51FfCmARYSVcK3pn005G3kX55di/P12/Wl/4c8gI X-Received: by 2002:a62:62c3:: with SMTP id w186-v6mr1771483pfb.5.1540477088997; Thu, 25 Oct 2018 07:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477088; cv=none; d=google.com; s=arc-20160816; b=eefUWDK8MkiXYYeQsquS6mIBuZwAvPuWPRkOn+I1JnZWi0YvCPfp+G7/6gHZpsUsrk n4eNI9GYp4lqEyvrtQGIWJcl1pV05qQUNNfH0rP6lNr3cGRuDkTyapP1mkCh3lVxgk+o BN/oMw+gz1DdITPHE/SHwc11nX/rpuvGMSgNkYg11aZhR9N6S1MSlOkdFn3s+WZVfMS7 Kv2Hup2ATv1SkhXtwR5rJTdq+1MdtDQip3IOEDE+JA07uTLjqEJyRhTJZzC0fzl8jrBZ F+On3MpDrwfBnV7qjH9v3Wu3XYMaelQ/dvYwhKSEj3TAszn7ZLfoxOmWSr63zGR3eKF4 lHjA== 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=g1ftFDQnveaXqt7dC+6J71VtPKLBdkVfJFX0kgBoqMI=; b=O0YrLcMmkT8W7tZfea4TsEahHu0Jb48rJhN62WDbJpxOAd/X8qUIADl0AYR6cOx3Xx wGqsRH1VxDxymwEjRYXDr0endG7xo6w8VjUJ7jJIVkc4K0AUEo66q1/fFsl6g5GRMSr+ 3idEgAkgJwvJvAdESKcQbbYX5TIajgRBNUVV7+JmmKi52zinwky6etJdcz2VUetzo8ng HThZKsui9UMjLV6mKS3b3E2OjU4rCgHgQh7rb1cWotg4NMtvIVpgjg4FDDIDqbnMlNIP 8u6ZDf7tr6Y9iE0TyN/2FlzFcSWpmeiOvJSjWOPKVi8f1BkAsa4N5oi9hE8qFtg/friN 3wrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HDtx+6nA; 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 t10-v6si8401182pgh.338.2018.10.25.07.17.39; Thu, 25 Oct 2018 07:18:08 -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=HDtx+6nA; 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 S1728028AbeJYWuE (ORCPT + 99 others); Thu, 25 Oct 2018 18:50:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728092AbeJYWtk (ORCPT ); Thu, 25 Oct 2018 18:49:40 -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 A287220848; Thu, 25 Oct 2018 14:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477003; bh=Wx16khg9vWFJw5gOXMnjXIOcAA6NliSgr6NNk1I2nFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDtx+6nAlEH9qa0czL6ykxSaVrOkgDW98sJ4o8Rp1XjWQzs0BhFUCMCLVw9Zo0ivz t0Dc4pVAAMLaoA3MGTDX5Vpn0Ckb1njII5mqAp7vjNZLcefkH9BdAaZLlvWICoMP7f FClh/DHT1+pL6D8J+a1d648Rhc8mqhW00P172doU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christophe Jaillet , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL 4.9 95/98] IB/mlx4: Fix an error handling path in 'mlx4_ib_rereg_user_mr()' Date: Thu, 25 Oct 2018 10:14:20 -0400 Message-Id: <20181025141423.213774-95-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: Christophe Jaillet [ Upstream commit 3dc7c7badb7502ec3e3aa817a8bdd9e53aa54c52 ] Before returning -EPERM we should release some resources, as already done in the other error handling path of the function. Fixes: d8f9cc328c88 ("IB/mlx4: Mark user MR as writable if actual virtual memory is writable") Signed-off-by: Christophe JAILLET Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx4/mr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index 0d4878efd643..ddd3182138ac 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c @@ -247,8 +247,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, } if (flags & IB_MR_REREG_ACCESS) { - if (ib_access_writable(mr_access_flags) && !mmr->umem->writable) - return -EPERM; + if (ib_access_writable(mr_access_flags) && + !mmr->umem->writable) { + err = -EPERM; + goto release_mpt_entry; + } err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry, convert_access(mr_access_flags)); -- 2.17.1