From patchwork Tue May 3 18:58:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Falak R Wani X-Patchwork-Id: 9007861 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0677BF29F for ; Tue, 3 May 2016 18:59:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0723320103 for ; Tue, 3 May 2016 18:59:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34FF0200E9 for ; Tue, 3 May 2016 18:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933835AbcECS7I (ORCPT ); Tue, 3 May 2016 14:59:08 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35687 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933291AbcECS7I (ORCPT ); Tue, 3 May 2016 14:59:08 -0400 Received: by mail-pf0-f175.google.com with SMTP id 77so14194929pfv.2; Tue, 03 May 2016 11:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=jMO6adnHfoTrY9mi3FwuFE6x6VDJc0mpjRyO2FjOV+I=; b=kYJCg7fITQiAMh89KagNUt61ak8oUxZs7zvHne30FLWD34EJSu4lv9XPhywLNwss9D 2qExtsoRPioBZSW4bz+kWWHmEpieyPO+G1HsPsnBZegwojMfCgdRTfqwUMzUFzt/Vxwk PInrLvgPVf2H+GKdT+noxr7+qTJ4fpj/WdbhgKyqWdzQYbh09oDaSR/9trNu0L8MCi0D 678fa5jRPKn6rAb93MAJclV/XW/aOolpuYyGaW5xds2902jODMCOA3mbpperQKf9Jsbz AAfijl2ZAPAteUT+MLViwtLMA/hpj/fU0PFA2GubvY5abNmVmPviZlt2irgLi/tMpQMp fQpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jMO6adnHfoTrY9mi3FwuFE6x6VDJc0mpjRyO2FjOV+I=; b=hT+vlPkA9yaXrTKYgxPXd/kUGjnROeXSXgbEBPcJFRJEsy4XB8owt6xIa4m+aNjNX+ a112KBd4f4C7eeYXwP3ANjNVGbjMTN2dYNJSU2P6V7No7d5xgAgYQlpI6KgUbWZizw9M pzAJkpmIIKBOZ9FTU5XfepLpLAUKIX7kz5tay0M8AogfU0ulUY9crYsLJr+KnJjN7+un NFqr1BVNGkjmPglQiB8ztu5pjNP6XECiwTJ/CgbU6IZOD6U1dO1dMCI08TczXCgGgToU s3ZNgIbhHqCtcE7yDjOAbd9givb0LAravZ1P9QtJgLIJgWxGR2am8lwUJeR4HmXzTdfp VZ/w== X-Gm-Message-State: AOPr4FWzYlu/s6CaY5e9LBSUYujIJeSFxcoamjJIq8QYst+jWE6D1wket9mWBWMaxq2VEw== X-Received: by 10.98.41.70 with SMTP id p67mr5883490pfp.93.1462301946767; Tue, 03 May 2016 11:59:06 -0700 (PDT) Received: from kp.domain.name ([110.235.28.83]) by smtp.gmail.com with ESMTPSA id 194sm693282pfv.8.2016.05.03.11.59.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 May 2016 11:59:05 -0700 (PDT) From: Muhammad Falak R Wani To: Herbert Xu Cc: "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: algif_skcipher: replace sg++ with sg_next() Date: Wed, 4 May 2016 00:28:08 +0530 Message-Id: <1462301939-23578-1-git-send-email-falakreyaz@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Never use sg++, always use sg = sg_next(sg). Scatterlist entries can be combined if the memory is contiguous but sg++ won't know about that. It sure would run on the slower side. But regardless, sg++ should never be used, only sg_next is safe. Signed-off-by: Muhammad Falak R Wani --- crypto/algif_skcipher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 28556fc..a668867 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -489,7 +489,7 @@ static int skcipher_all_sg_nents(struct skcipher_ctx *ctx) sg = sgl->sg; while (!sg->length) - sg++; + sg = sg_next(sg); nents += sg_nents(sg); } @@ -553,7 +553,7 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, sg = sgl->sg; while (!sg->length) - sg++; + sg = sg_next(sg); used = min_t(unsigned long, ctx->used, iov_iter_count(&msg->msg_iter)); @@ -676,7 +676,7 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg, sg = sgl->sg; while (!sg->length) - sg++; + sg = sg_next(sg); skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used, ctx->iv);