Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6267061imu; Mon, 21 Jan 2019 06:06:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN7I0D14DQvEfapbEWvyZWFLGxL8HfDEbwhnaXYKNgud9njuWbhtssBMFsVgazYVshQGvonC X-Received: by 2002:a63:111c:: with SMTP id g28mr27917258pgl.85.1548079605167; Mon, 21 Jan 2019 06:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079605; cv=none; d=google.com; s=arc-20160816; b=DqD4JzfjuPoYI/uDx81TZ52EMvcvQSwp0bzQJX7MhYUjB/As6r5ZWI2G/F0NvEZRuf QhF7H/7S7N7fzfSDab1IePM4HFyW0z2OuvXHRsTEWIoLU9FIk4g2AKYEP1j66Rnsl0DF ln0+1dPCKxYxadTkVid1b9WT3kS2bbBfXgpY+rvszTwrNDm1xADw3uDWvULT/oUMm+qU NpUNNkC8TvEfzITXQoRN1vcLMSS0pRL6wU2cpfA9pfk7wfcPzhWUwH9smzjAu49bOVU9 elQiKoZq44QY0Bg+vYMt8vhV/lPnJR9pzfBMFRPlqjUSQu+0j4+iHL205BiNeGQBtA2b borA== 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:dkim-signature; bh=Nzo4vx435c1t9KqgBzatp9ZNSrS+298zR9aItK3fqu0=; b=wpkzZsTBfTX3joYHhYNFZJVdsHvFYMmxKD2hRfgXM09zHrsKvpgq1cZ5M9mrhlV2Ee HZfUq++prg0//3N0SW68WRjGywXMlEDIRU4kYutWkOCAViXDjhXBTNvReCUoC0F7hb77 5l75Zalwvzj7ckJPbfDS8ZZ1xcHYkT8uWLmmkfYKClYZ0M/sIqe7Akiy6+Cg7NTln6la t4inrJrrhW9Ria/dm72gNQ8jnFCDKHdR2iKE6dS5LszUfZpG/Jw5gO/Sc4ohrRYnUVIv dSysAnNQDcJitpynkhXX7kPTvQW14U9OOQ6a6OKIdRkcdW+6+m7IdUpkTcgNVXmDHkSI p/AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vLG1zUVC; 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 v69si12896427pgd.284.2019.01.21.06.06.29; Mon, 21 Jan 2019 06:06:45 -0800 (PST) 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=vLG1zUVC; 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 S1731730AbfAUOCJ (ORCPT + 99 others); Mon, 21 Jan 2019 09:02:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:49390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731883AbfAUOCD (ORCPT ); Mon, 21 Jan 2019 09:02:03 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC76521736; Mon, 21 Jan 2019 14:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079322; bh=+fZfGilqJL4+hZp51QePJDsxJTSNuNTS8sscElUh0ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLG1zUVCfT1vNWgm4E7oDNmFXxmdaskox0Zqy7BPtF9aulQT+esOhj/TF8NA3CnXf +ZhT1Hv9gXPTC1Wc27VasLc7FJxA8m/9dt1QZd3vi1MWmJXfbBk6sdoTexst+5azD7 37xIREYJ+EJvkqJomLgQO3xsg9ce8nAbM2kOc4S0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , =?UTF-8?q?Horia=20Geant=C4=83?= , Herbert Xu Subject: [PATCH 4.19 37/99] crypto: talitos - reorder code in talitos_edesc_alloc() Date: Mon, 21 Jan 2019 14:48:29 +0100 Message-Id: <20190121134915.304297217@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christophe Leroy commit c56c2e173773097a248fd3bace91ac8f6fc5386d upstream. This patch moves the mapping of IV after the kmalloc(). This avoids having to unmap in case kmalloc() fails. Signed-off-by: Christophe Leroy Reviewed-by: Horia Geantă Cc: stable@vger.kernel.org Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/talitos.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1361,23 +1361,18 @@ static struct talitos_edesc *talitos_ede struct talitos_private *priv = dev_get_drvdata(dev); bool is_sec1 = has_ftr_sec1(priv); int max_len = is_sec1 ? TALITOS1_MAX_DATA_LEN : TALITOS2_MAX_DATA_LEN; - void *err; if (cryptlen + authsize > max_len) { dev_err(dev, "length exceeds h/w max limit\n"); return ERR_PTR(-EINVAL); } - if (ivsize) - iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); - if (!dst || dst == src) { src_len = assoclen + cryptlen + authsize; src_nents = sg_nents_for_len(src, src_len); if (src_nents < 0) { dev_err(dev, "Invalid number of src SG.\n"); - err = ERR_PTR(-EINVAL); - goto error_sg; + return ERR_PTR(-EINVAL); } src_nents = (src_nents == 1) ? 0 : src_nents; dst_nents = dst ? src_nents : 0; @@ -1387,16 +1382,14 @@ static struct talitos_edesc *talitos_ede src_nents = sg_nents_for_len(src, src_len); if (src_nents < 0) { dev_err(dev, "Invalid number of src SG.\n"); - err = ERR_PTR(-EINVAL); - goto error_sg; + return ERR_PTR(-EINVAL); } src_nents = (src_nents == 1) ? 0 : src_nents; dst_len = assoclen + cryptlen + (encrypt ? authsize : 0); dst_nents = sg_nents_for_len(dst, dst_len); if (dst_nents < 0) { dev_err(dev, "Invalid number of dst SG.\n"); - err = ERR_PTR(-EINVAL); - goto error_sg; + return ERR_PTR(-EINVAL); } dst_nents = (dst_nents == 1) ? 0 : dst_nents; } @@ -1425,10 +1418,10 @@ static struct talitos_edesc *talitos_ede alloc_len += sizeof(struct talitos_desc); edesc = kmalloc(alloc_len, GFP_DMA | flags); - if (!edesc) { - err = ERR_PTR(-ENOMEM); - goto error_sg; - } + if (!edesc) + return ERR_PTR(-ENOMEM); + if (ivsize) + iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); memset(&edesc->desc, 0, sizeof(edesc->desc)); edesc->src_nents = src_nents; @@ -1445,10 +1438,6 @@ static struct talitos_edesc *talitos_ede DMA_BIDIRECTIONAL); } return edesc; -error_sg: - if (iv_dma) - dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE); - return err; } static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv,