From patchwork Mon Oct 8 19:17:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10631367 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FFE615E9 for ; Mon, 8 Oct 2018 19:39:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C1829B56 for ; Mon, 8 Oct 2018 19:39:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07D9729B81; Mon, 8 Oct 2018 19:39:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93AB129B56 for ; Mon, 8 Oct 2018 19:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbeJICxH (ORCPT ); Mon, 8 Oct 2018 22:53:07 -0400 Received: from gateway32.websitewelcome.com ([192.185.145.182]:16572 "EHLO gateway32.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeJICxH (ORCPT ); Mon, 8 Oct 2018 22:53:07 -0400 X-Greylist: delayed 1357 seconds by postgrey-1.27 at vger.kernel.org; Mon, 08 Oct 2018 22:53:07 EDT Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway32.websitewelcome.com (Postfix) with ESMTP id B498B3084603 for ; Mon, 8 Oct 2018 14:17:14 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 9b1mgdzLcaSey9b1mg0KQI; Mon, 08 Oct 2018 14:17:14 -0500 X-Authority-Reason: nr=8 Received: from 174.206.93.92.rev.sfr.net ([92.93.206.174]:49110 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1g9b1m-000HlO-2e; Mon, 08 Oct 2018 14:17:14 -0500 Date: Mon, 8 Oct 2018 21:17:12 +0200 From: "Gustavo A. R. Silva" To: Antoine Tenart , Herbert Xu , "David S. Miller" , Kees Cook Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] crypto: inside-secure: safexcel - fix memory allocation Message-ID: <20181008191712.GA12892@embeddedor.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 92.93.206.174 X-Source-L: No X-Exim-ID: 1g9b1m-000HlO-2e X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174.206.93.92.rev.sfr.net (embeddedor) [92.93.206.174]:49110 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 5 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be sizeof(*priv->ring[i].rdr_req). Addresses-Coverity-ID: 1473962 ("Sizeof not portable") Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance") Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook Acked-by: Antoine Tenart --- drivers/crypto/inside-secure/safexcel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 86c699c1..bc6c5cb 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1066,7 +1066,7 @@ static int safexcel_probe(struct platform_device *pdev) priv->ring[i].rdr_req = devm_kcalloc(dev, EIP197_DEFAULT_RING_SIZE, - sizeof(priv->ring[i].rdr_req), + sizeof(*priv->ring[i].rdr_req), GFP_KERNEL); if (!priv->ring[i].rdr_req) { ret = -ENOMEM;