{"id":808351,"url":"http://patchwork.ozlabs.org/api/patches/808351/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170831170724.3747-1-colin.king@canonical.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170831170724.3747-1-colin.king@canonical.com>","list_archive_url":null,"date":"2017-08-31T17:07:24","name":"[next] net/mlx4_core: fix incorrect size allocation for dev->caps.spec_qps","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"bb920c13505a149a7ae12540122cac9cb09f123c","submitter":{"id":2900,"url":"http://patchwork.ozlabs.org/api/people/2900/?format=json","name":"Colin Ian King","email":"colin.king@canonical.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170831170724.3747-1-colin.king@canonical.com/mbox/","series":[{"id":885,"url":"http://patchwork.ozlabs.org/api/series/885/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=885","date":"2017-08-31T17:07:24","name":"[next] net/mlx4_core: fix incorrect size allocation for dev->caps.spec_qps","version":1,"mbox":"http://patchwork.ozlabs.org/series/885/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808351/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808351/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjphp4pnCz9s81\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 03:07:38 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751888AbdHaRH1 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 31 Aug 2017 13:07:27 -0400","from youngberry.canonical.com ([91.189.89.112]:53315 \"EHLO\n\tyoungberry.canonical.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750813AbdHaRH0 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 31 Aug 2017 13:07:26 -0400","from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost)\n\tby youngberry.canonical.com with esmtpsa\n\t(TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76)\n\t(envelope-from <colin.king@canonical.com>)\n\tid 1dnSw9-00039D-16; Thu, 31 Aug 2017 17:07:25 +0000"],"From":"Colin King <colin.king@canonical.com>","To":"Tariq Toukan <tariqt@mellanox.com>, netdev@vger.kernel.org,\n\tlinux-rdma@vger.kernel.org","Cc":"kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org","Subject":"[PATCH][next] net/mlx4_core: fix incorrect size allocation for\n\tdev->caps.spec_qps","Date":"Thu, 31 Aug 2017 18:07:24 +0100","Message-Id":"<20170831170724.3747-1-colin.king@canonical.com>","X-Mailer":"git-send-email 2.14.1","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"8bit","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Colin Ian King <colin.king@canonical.com>\n\nThe current allocation for dev->caps.spec_qps is for the size of the\npointer and not the size of the actual  mlx4_spec_qps structure.  Fix\nthis by using the correct size.   Also splint allocation over a few\nlines to make it cppcheck clean on overly wide lines.\n\nDetected by CoverityScan, CID#1455222 (\"Wrong sizeof argument\")\n\nFixes: c73c8b1e47ca (\"net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap\")\nSigned-off-by: Colin Ian King <colin.king@canonical.com>\n---\n drivers/net/ethernet/mellanox/mlx4/qp.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c\nindex b16fc441609e..728a2fb1f5c0 100644\n--- a/drivers/net/ethernet/mellanox/mlx4/qp.c\n+++ b/drivers/net/ethernet/mellanox/mlx4/qp.c\n@@ -845,8 +845,9 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)\n \n \t\t/* In mfunc, calculate proxy and tunnel qp offsets for the PF here,\n \t\t * since the PF does not call mlx4_slave_caps */\n-\t\tdev->caps.spec_qps = kcalloc(dev->caps.num_ports, sizeof(dev->caps.spec_qps), GFP_KERNEL);\n-\n+\t\tdev->caps.spec_qps = kcalloc(dev->caps.num_ports,\n+\t\t\t\t\t     sizeof(*dev->caps.spec_qps),\n+\t\t\t\t\t     GFP_KERNEL);\n \t\tif (!dev->caps.spec_qps) {\n \t\t\terr = -ENOMEM;\n \t\t\tgoto err_mem;\n","prefixes":["next"]}