Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756474AbcCBAt1 (ORCPT ); Tue, 1 Mar 2016 19:49:27 -0500 Received: from mail177-1.suw61.mandrillapp.com ([198.2.177.1]:56022 "EHLO mail177-1.suw61.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755388AbcCAX4k convert rfc822-to-8bit (ORCPT ); Tue, 1 Mar 2016 18:56:40 -0500 From: Greg Kroah-Hartman Subject: [PATCH 4.4 189/342] drm/amdgpu: use post-decrement in error handling X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , =?utf-8?Q?Christian=20K=C3=B6nig?= , Rasmus Villemoes , Alex Deucher Message-Id: <20160301234534.049329583@linuxfoundation.org> In-Reply-To: <20160301234527.990448862@linuxfoundation.org> References: <20160301234527.990448862@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.dafc21a6b2224362ad4d1c7db31085d6 X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:54:46 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1170 Lines: 32 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rasmus Villemoes commit 09ccbb74b6718ad4d1290de3f5669212c0ac7d4b upstream. We need to use post-decrement to get the pci_map_page undone also for i==0, and to avoid some very unpleasant behaviour if pci_map_page failed already at i==0. Reviewed-by: Christian König Signed-off-by: Rasmus Villemoes Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -712,7 +712,7 @@ static int amdgpu_ttm_tt_populate(struct 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); if (pci_dma_mapping_error(adev->pdev, gtt->ttm.dma_address[i])) { - while (--i) { + while (i--) { pci_unmap_page(adev->pdev, gtt->ttm.dma_address[i], PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); gtt->ttm.dma_address[i] = 0;