Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1945228imm; Thu, 24 May 2018 03:22:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqSY1w/fm5z5SIZr0Ke4bkUckxDAVAKb5/Xx1CUtcWVkB6t+R4FzFKkJI0Gziw/IuYXGXzn X-Received: by 2002:a63:7c01:: with SMTP id x1-v6mr5319839pgc.286.1527157375532; Thu, 24 May 2018 03:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157375; cv=none; d=google.com; s=arc-20160816; b=Ay5VzzKVGKvPTA6lLSV7XSLgYhhbECnlrwPgNiG3OwvWGu/wJ1DTGaGilttsp6I28Z AOfs5PB2900L8YnJOHSH7PRrycfVWFPjrjrvhlLqHRJVLFAp9RoWDZHGb8V9wUGQaDCY atEReIiP9Crxpg/A6Eooi8bSJtnxoUOiqWNjNAFKi8xcO4KqmNumdNyT3oySM0K+5dyC 0a4qRjnm3U32k9MF+uOez7/00hJJAoL9vIcwz9A8uf4SKVBdYJIHH/g913YudWO6+lHR P3QlOELdQbMstueK51HTPYlEoN7CdM0/T1Ywc0GtKqs9T0k6OHOp959G2JT5w+byTjvu 4TwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KZ6WNtoq2dvRUmITo/WuysIGOFatUaLnUwl2NOKmEuQ=; b=LR86fCyT/Qnh//FWaXn+VnUZ/2xk7l6xjzjAitk2NfKKNcsp0hzdjlF1wUugV9h2Xy 4zP0rX+fNLwWKSxbVR/1S74BYBxLsR6Z3GDkEdpL4m65K6Io/CxXN912kmNWsZ1Zvsl2 +2sHteuZC1qyV3nYYSsiKx53JtBPxC794DMnAA+tBaFe13sf4Erkg0vaZCstmPToVgQ8 KzkGLLtFpAXNRyrjLizwbFZurkSv2ziKZT/g6GwszPJ9/+M6AGvhcLzP5STWEs86X5nq VffPkso6ZHEwqIrh3RCEsrjILopyd5hU055/yyYneBwQ06FDXEN6cGvfL3h2sOjokgWA hH2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g8DuDWQl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si20000091plr.332.2018.05.24.03.22.41; Thu, 24 May 2018 03:22:55 -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=@kernel.org header.s=default header.b=g8DuDWQl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031759AbeEXKWC (ORCPT + 99 others); Thu, 24 May 2018 06:22:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:51422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031157AbeEXKC7 (ORCPT ); Thu, 24 May 2018 06:02:59 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DCB5520847; Thu, 24 May 2018 10:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156179; bh=onnI2EMRJkG7ovStjH+K8EfkPXPhntpPsASq4T48I6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g8DuDWQlzkAuwzvHnJANja5B5WXaGtY/wIIf2PLm+RMviNEiZzpXUlZsSrcamOVLI NoPVedic6v9NkLrtvBOrF2bzFC+W274Z0eeprQ5Gco6XUVIQ5BGbvzWhjmBtaF9ASO bat9C0ZPS/9svX7pzY1TJSILXALPJ1Knh9ei9ifQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ioana Radulescu , Dan Carpenter Subject: [PATCH 4.16 091/161] staging: fsl-dpaa2/eth: Fix incorrect kfree Date: Thu, 24 May 2018 11:38:36 +0200 Message-Id: <20180524093029.308672095@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ioana Radulescu [ Upstream commit 6a9bbe53db9a5aa0be9788aa8a2c250dee55444b ] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- 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_ /* 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_ 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 dpaa 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);