From patchwork Wed Jul 27 19:17:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 9250345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3EF6F6077C for ; Wed, 27 Jul 2016 19:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ECDB2624C for ; Wed, 27 Jul 2016 19:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2322526530; Wed, 27 Jul 2016 19:17:53 +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=-6.9 required=2.0 tests=BAYES_00,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 9CC302624C for ; Wed, 27 Jul 2016 19:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754303AbcG0TRt (ORCPT ); Wed, 27 Jul 2016 15:17:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758337AbcG0TRm (ORCPT ); Wed, 27 Jul 2016 15:17:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA8D481223; Wed, 27 Jul 2016 19:17:41 +0000 (UTC) Received: from hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com (hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com [10.16.184.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6RJHenq032006; Wed, 27 Jul 2016 15:17:41 -0400 From: Jarod Wilson To: linux-rdma@vger.kernel.org Cc: Jarod Wilson , Yishai Hadas Subject: [PATCH libmlx5 1/6] fix size in malloc of qp->sq.wr_data Date: Wed, 27 Jul 2016 15:17:22 -0400 Message-Id: <1469647047-7544-2-git-send-email-jarod@redhat.com> In-Reply-To: <1469647047-7544-1-git-send-email-jarod@redhat.com> References: <1469647047-7544-1-git-send-email-jarod@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 27 Jul 2016 19:17:41 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Coverity complaint: 1. libmlx5-1.2.1/src/verbs.c:989: suspicious_sizeof: Passing argument "qp->sq.wqe_cnt * 8UL /* sizeof (qp->sq.wr_data) */" to function "malloc" and then casting the return value to "uint32_t *" is suspicious. 2. libmlx5-1.2.1/src/verbs.c:989: remediation: Did you intend to use "sizeof (*qp->sq.wr_data)" instead of "sizeof (qp->sq.wr_data)"? # 987| } # 988| # 989|-> qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(qp->sq.wr_data)); # 990| if (!qp->sq.wr_data) { # 991| errno = ENOMEM; The other mallocs in this same area properly use sizeof(*foo), this one should too. CC: Yishai Hadas Signed-off-by: Jarod Wilson --- src/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verbs.c b/src/verbs.c index 40f66c6..7ed394e 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -986,7 +986,7 @@ static int mlx5_alloc_qp_buf(struct ibv_context *context, return err; } - qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(qp->sq.wr_data)); + qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data)); if (!qp->sq.wr_data) { errno = ENOMEM; err = -1;