From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B43215A7B8; Tue, 23 Jan 2024 01:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705974334; cv=none; b=RdqD+wdCeFfwySe+A0md1TcybRrLUijA+9xEQWvFHLRi5fKGP8IQ+yzHGQB0FYZ3Vbezx2EMf/DqaI40OHOiVvweMwVE6+lltRa0yKTISe6ehrZfTqzDNaiQJ7OJxUfY0yJLvA8+Py1XCcu/olBe/m3y6Xt3iNu4z2L2wPNt4dw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705974334; c=relaxed/simple; bh=0/dk9Bp0jyIfOeTXGaYJUK8RxSdErULahAKXDFTZHFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GhSco2Srq4k5Ia47wqRalsKO7l3dmQt0mG3LV+kAjktRU6Knhkks9BLNapir4ec6TWZUWt/9quQ6pTNJsJqTorM5QRH4vJ0SJql4VxctFmfaedJLTm1UKS4ODBxRRcQm8xP+dXXy1m2SvE1enOLYg8DxmuiD2RM/VOxH+N80ozA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=x0WSMfwz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="x0WSMfwz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78D13C433F1; Tue, 23 Jan 2024 01:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705974334; bh=0/dk9Bp0jyIfOeTXGaYJUK8RxSdErULahAKXDFTZHFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x0WSMfwz6Ex8difcW6yYG5VxDiqMCFpF42OxBjHALeq7UyeBKoAfeTYaKjVMFUrnU /u7AJQThDkU9rSqlciFno0/qTGxqLj6MaoSdowFG4dWuw+VF8Y2nVyQW8uU4Asi5ui IZzc6wVJClEgB8jSHz3IOx/vdI/uTFBQXnb3ZMRw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ovidiu Panait , Herbert Xu , Sasha Levin Subject: [PATCH 6.6 053/583] crypto: sahara - fix error handling in sahara_hw_descriptor_create() Date: Mon, 22 Jan 2024 15:51:44 -0800 Message-ID: <20240122235813.756766765@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235812.238724226@linuxfoundation.org> References: <20240122235812.238724226@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ovidiu Panait [ Upstream commit ee6e6f0a7f5b39d50a5ef5fcc006f4f693db18a7 ] Do not call dma_unmap_sg() for scatterlists that were not mapped successfully. Fixes: 5de8875281e1 ("crypto: sahara - Add driver for SAHARA2 accelerator.") Signed-off-by: Ovidiu Panait Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/sahara.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index 55cfe51575b9..e86df3c51787 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -483,13 +483,14 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev) DMA_TO_DEVICE); if (!ret) { dev_err(dev->device, "couldn't map in sg\n"); - goto unmap_in; + return -EINVAL; } + ret = dma_map_sg(dev->device, dev->out_sg, dev->nb_out_sg, DMA_FROM_DEVICE); if (!ret) { dev_err(dev->device, "couldn't map out sg\n"); - goto unmap_out; + goto unmap_in; } /* Create input links */ @@ -537,9 +538,6 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev) return 0; -unmap_out: - dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg, - DMA_FROM_DEVICE); unmap_in: dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE); -- 2.43.0