Received: by 10.213.65.68 with SMTP id h4csp1214759imn; Wed, 14 Mar 2018 13:06:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELtK0AMOfH2Gwy5sezOV51EP1p+KhlLZgZ8VzL29OByW5Q4vUXv3ITetrXtDC+/geVUT1RJt X-Received: by 10.99.95.5 with SMTP id t5mr848237pgb.295.1521058010728; Wed, 14 Mar 2018 13:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521058010; cv=none; d=google.com; s=arc-20160816; b=wkzELVmYQwNcI35nmkWMH5Nx6pXIGp9RGSNEpCHz0Eurk7jItkX0uEBv5lM5ipde5l Qbp9B7OcdBYcYjhCyYyT7G0YWo75Gt5cehtPDqpaqlehYvEVKhDzPJ9Mh07i3EBjOB0r OQ1vBcfqnWqMVwqqFaYJIf8puz2miNPM2wjBO/Sl6j+wPFifmbqlJJolVBk3R7QZ3Hvb /1ue6bSXmN7MxROmKNKRxcoQT+tK8URDAQPmTiG/wKqIauh+38HHYXlmkETSDXLr2ZT5 S74kTV4rQzuSs1Png88HCm9GeZ6h5iHy7O1SxAthlrCskA5YeL/tPYNVX4dm6Gaeophv K5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=nFzdrVBXfIKRiyjWG2gb6XjwgYF3pz5tq+U2XLIIUks=; b=HYLc1FD53PdTkvIs33nKPYGmo6YsjjjldojWpNe5J+QHMsAylg+WjsKi5Yx0Fn4hHG fOJrxpqYTGsxnwBRZSEsGtSa4YRmuo5nWg9+CCuzyfItfYC/mWWnS5ozH/hVerXbrBCu JsrSIDLWStrJYGoB+tKIKTGPbPR1IFiFjUuP/X2M1hpQMdEbmv04rCqosoVixRD7ZsvO qI9IfFV9zvZZSMQbf/2FBgx8Lsd1xQzR2tXrSubWDMB/LcWpEY8iO33Y4ChJLpUX6j0h yKyGybZAfkDRxKgurcFkuXLbgpUwk1h77JBK6i6y3rPziVjCxtKxWPNYh+NVCQQoDVAw rloA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=LU1FUKpH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd8-v6si2462035plb.288.2018.03.14.13.06.36; Wed, 14 Mar 2018 13:06:50 -0700 (PDT) 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=@nxp.com header.s=selector1 header.b=LU1FUKpH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbeCNUFL (ORCPT + 99 others); Wed, 14 Mar 2018 16:05:11 -0400 Received: from mail-db5eur01on0062.outbound.protection.outlook.com ([104.47.2.62]:34256 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750950AbeCNUFJ (ORCPT ); Wed, 14 Mar 2018 16:05:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nFzdrVBXfIKRiyjWG2gb6XjwgYF3pz5tq+U2XLIIUks=; b=LU1FUKpHViY7RBTy1iTZdM88lVAxOK8DnYUCAd2hGpbj1z/3fkmLX9bi6Lr4YsliJkxXwMPtgZBB2IQ/na0S9o0sSA9RB3yDIfFa8U8x5oDQ7zVW3m1hEVYWnfd+4EB/aRaitd+obTXEY6ZB1DghjOyRpbL8AGwTlTGqO7fkmtM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ruxandra.radulescu@nxp.com; Received: from rhuath.am.freescale.net (192.88.168.1) by VI1PR0402MB2703.eurprd04.prod.outlook.com (2603:10a6:800:b4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Wed, 14 Mar 2018 20:05:05 +0000 From: Ioana Radulescu To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com Subject: [PATCH] staging: fsl-dpaa2/eth: Fix incorrect kfree Date: Wed, 14 Mar 2018 15:04:51 -0500 Message-Id: <20180314200451.27738-1-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.168.1] X-ClientProxiedBy: BN6PR11CA0039.namprd11.prod.outlook.com (2603:10b6:404:4b::25) To VI1PR0402MB2703.eurprd04.prod.outlook.com (2603:10a6:800:b4::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 681732c3-5ae9-48f1-75df-08d589e6e19a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR0402MB2703; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0402MB2703;3:k+c7xVFAtO8/Wx52Y+hnft7Ib+a1yYvtbItjeUhySoP13qDJgyLLmbPfkNNqml25wETO/gHMVnnGwUJHJDhKAzHmRllc1F9cXILvfwtJYLrxDj9YhN5HhUUiwUA+HVyMuXOsAsoq+uJYzfe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rAyEyraCh+0qh+o1ShT7Q7tmPaYpMrGJB6/Ot5EqsxWMmAz4Xh0Q7rOI93wY44zfJq09VhzUa8hXS9phR7/KNnV3dZJVbRRh1nb64QWYhIrWrZ/mtyHUyAVvWgDhhHtpYSZwVkslcCtcOtn/tmJjoTz6gQr3gPW41tXBllosbLaHHNt+FN8F0qD2SwiOtoO9AyVEBKr4HcxF2w6qRuILSB;4:vTI6ue05JjCBq/ccb0+oXbDbumd/ykEynx0hUsDO3ibL1WOacz0QAUCWyHLxD/aF4PXcnTps7hR4grqxUkI0Y38PWBPJh8IKfh9sDGznOfLNQcTaes4QJ5w1KENJ3kMwZfyxpCidFxlyaw9inFzlx9v0lXWxO1uzUBgEtWIsZ770XU9Y1tfovwHxtf76sQhrd1svSl9/IfeHRJZWCyhYRzSpeX24doeMrSZ5E9lSUFvGwKnQ+wKS34wB0xKvbJkGK0XrJ/1Wzir+Bu6+TEzwiyoQYl/jDUw9TAyedauGBsI9i+CdlGmDVBioagPuVYvT4FcDFHf7xgZC5llZMF7OwPG/P91p38oLS9zBVsPSVJ8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231221)(944501244)(52105095)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:VI1PR0402MB2703;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0402MB2703; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(376002)(396003)(39380400002)(39860400002)(346002)(199004)(189003)(16526019)(2361001)(26005)(66066001)(6666003)(47776003)(7736002)(305945005)(51416003)(50466002)(48376002)(52116002)(105586002)(3846002)(386003)(1076002)(186003)(2906002)(25786009)(6916009)(1857600001)(2351001)(6506007)(6116002)(86362001)(6512007)(316002)(4326008)(8936002)(81166006)(53936002)(36756003)(106356001)(8676002)(81156014)(68736007)(50226002)(6486002)(97736004)(5660300001)(478600001)(16586007);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB2703;H:rhuath.am.freescale.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0402MB2703;23:XAc6g4Je3Ca/oIRRbmjmxE4nm5Y1zfU6C70VS8U?= =?us-ascii?Q?u5RYHgwAsNTDFJ5cfXsu90cXh8pVwQ0CxyYHNhR6Rt/8qq9bKTvwon/6EZEV?= =?us-ascii?Q?G5QtzJ++K2WDrc14Qx7jzfjyeJRWA7cDo7Hhe/Age3OTwlVrBX+gPV79SHc6?= =?us-ascii?Q?Xb/S0wAo8eD5wtoA2lLfVw8xb20iYiM8mYRevv7ZMr8Dz6SdBgraDaGz3P7d?= =?us-ascii?Q?UMvF6aG51ErRa6+1jh5lpGWE0pv4hBZSYYdQLS3C0FYFEF7/dhywWZxo6mdZ?= =?us-ascii?Q?5ZC8N4E564OSCFLDb8tvVJUO6Y9CiMsgaigh8NzbkDKGG1oowWSvb1VTIlv+?= =?us-ascii?Q?G0Er32YMGSQIwo06twMvO4XH82bUuYrrIRz/zlgxZSpxFwqgsttlBTQuUFC4?= =?us-ascii?Q?6we1egcbgcP+/3L2w8GsT6SfFoBHBSJDPwOgwaRv0uc9drdZCdxYTcxuhi8C?= =?us-ascii?Q?TQXRiyt69TObp6q45j5qtpb/vvG01yzRDWcrYoAKc7YPP9t7pShYA14I7jpp?= =?us-ascii?Q?JUmPysMd0n2VvHXrwx7slyKOEVwuGMgnZzYuqKWTr1AKgw8X4HbiO3DhGnJ2?= =?us-ascii?Q?LJwphLYj2DR2pBBVWRShmSdhd4b3JRvqZPydMKGtKuBkzs6BoatWGHeUznmz?= =?us-ascii?Q?jZE1kjXJOwRTEHgVN7Fps4l1kjJxhXBK2IjCmrvjXJcdGjqDouvyb6EZ3hhC?= =?us-ascii?Q?zPGOAZ1raa/PmdleKGZGfYCnVjMBcYi11TNqSJmyQm6viEoMFFdNEKjEkHG5?= =?us-ascii?Q?SwFNYZTavXhabdpxIOSEXyaWsN6azAYGsc6nbPhFCheA47eY2MuZcAveQjPt?= =?us-ascii?Q?udnWXQ4VIIs6Jd9WIa9r2JYvzsSPtEB9TNDC1YjyzorL5OoD98AXibnrRFN0?= =?us-ascii?Q?KL89RiR4g8Crd8iieY6cUH8RYcGkkNWE0rfzpY9IhrMs4xAif4kv6dLT4Bus?= =?us-ascii?Q?RhggNEdy5+89eoj2rmFDeKSxgGhEIyn3ge4RvhdSQPFMzL/RvoAiluNnmi+f?= =?us-ascii?Q?s61nU5ttCjDY8aQ6QB9iTV2jUn3Bz7MmfJ026ujershzNkrLQ2mVgYcKeuqv?= =?us-ascii?Q?jHtxshLsN5FYX1JyR8NTe4BTGICxuHNpFllYXaeZh9uZ5DWYaXisOwyvbwzU?= =?us-ascii?Q?W9n4IQEQ1dxv012G0jc23yspRrm9IFJWw?= X-Microsoft-Antispam-Message-Info: etS7aDAkKcBeChLCylpA7kgMdUoxvSpAejyW3Z+jBoSxrt81moZ1s/D79PCqAfU2YxpyXscsN4u2JO3MTx29CXm7QkBXMcJ36xS/jbxKS+NXmA/2SCGeXnNqvreULeDqOPuNio2yw88kFIqSMa5aETT34YqI+l0Yc0d9aTdMZHMieNzWqy4IrW8XK0+138r+ X-Microsoft-Exchange-Diagnostics: 1;VI1PR0402MB2703;6:6gf3Ylg/ptlXAWPHHUAGoFc+NYAliGCOOfKG/fY1MI9hZwHHD4mEjtF/WOYMO3jyMw2P5UJ4866EkRFaRol1lAP8i7vuKAmningUjhMq/2HX31/sdNHyTpSH6VcTOEr2TrezvaIeC9wWiFdwSCgTh5vK9P5/ZjL4uFyyhg8EmJ8JvGgjf8XE4k+Zkqg17P+SC4Rmr4cSur22/CheEuzlzIItJaVvTredZJ0BS58cPG3WmlWfV1F9pRQumEfoGCpistHPTzGZnMqWb/euiSDC1NLk2uwMwiJP4g+BKYnIflmIdAy5RNcjesL3bVjhxNQbsCXwqcFVZeXz1gOORME84AFAWp17UaIbHp2f8eBoUsE=;5:r5zCZS7fxCEE2OrjPa0baTQzwEdUO6E2m/4Gs37zu9IgoOpVUBtGvqxu0WtUNlqHZJEct5VVgxOpQKKn+Ct2qBSbQmE2aH2JmateBWzo1AKkCMoLLX9E4/9/IFI7QsVshTuKwpWxwCpNF5W0QeFaJj4LYmrINR3lYitnb0tQQQU=;24:TMOtTXwK1MY6frrShNM5tCANIGNfajIR0CfPz58/wXiQcKVrGXywHLFttp963fFd6U+I0jjdd+vlZ2h28857+QBqSp0sSnDgb13JjSfQBHY=;7:hJa5c1TmiADX0bSDzRHpRv7LRlBXnBTM07ikeSjQQgaM4AgueYa7V7kVNSpUH91ZgIsXcmvnJY3+x0ctxRbZlovozqkN/vHAoMhbQGRxq1EaJjuRZa6aGnV6sztfncviv3HWV0Qz1hj7umpL5os13TnPFzADDy6D78dI/sO9Xxr5H5M/c7+QxuLCDegP4nwjbi1vY4XOuSvII1UEcg0DT7GoHtzhGVlPfm0RV2B5hZAFceqSTm/cBnWtr21SkTOU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 20:05:05.2179 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 681732c3-5ae9-48f1-75df-08d589e6e19a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2703 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use netdev_alloc_frag() instead of kmalloc to allocate space for the S/G table of egress multi-buffer frames. This fixes a bug where an unaligned pointer received from the allocator would be overwritten with the 64B aligned value, leading to a wrong address being later passed to kfree. Signed-off-by: Ioana Radulescu Reported-by: Dan Carpenter --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index c81a01f..f013af6 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -374,12 +374,14 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv, /* Prepare the HW SGT structure */ sgt_buf_size = priv->tx_data_offset + sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs); - sgt_buf = kzalloc(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN, GFP_ATOMIC); + sgt_buf = netdev_alloc_frag(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN); if (unlikely(!sgt_buf)) { err = -ENOMEM; goto sgt_buf_alloc_failed; } sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN); + memset(sgt_buf, 0, sgt_buf_size); + sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset); /* Fill in the HW SGT structure. @@ -421,7 +423,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv, return 0; dma_map_single_failed: - kfree(sgt_buf); + skb_free_frag(sgt_buf); sgt_buf_alloc_failed: dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL); dma_map_sg_failed: @@ -525,9 +527,9 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv, return; } - /* Free SGT buffer kmalloc'ed on tx */ + /* Free SGT buffer allocated on tx */ if (fd_format != dpaa2_fd_single) - kfree(skbh); + skb_free_frag(skbh); /* Move on with skb release */ dev_kfree_skb(skb); -- 2.7.4