From patchwork Thu Apr 5 11:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10324439 X-Patchwork-Delegate: kvalo@adurom.com 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 5342B60541 for ; Thu, 5 Apr 2018 11:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 420B82913C for ; Thu, 5 Apr 2018 11:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35F7C29154; Thu, 5 Apr 2018 11:23:30 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 AC4952913C for ; Thu, 5 Apr 2018 11:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751406AbeDELX2 (ORCPT ); Thu, 5 Apr 2018 07:23:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:56296 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbeDELX0 (ORCPT ); Thu, 5 Apr 2018 07:23:26 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w35BDod5076287; Thu, 5 Apr 2018 11:23:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=mR+//4AO2TgeeV+q9NHgbP8SiQuy5z7/mkcz5hkQOKw=; b=pbC9K12JMd4MiUicDnn9zKzhuZITwTxDn8Gzp09cuM7ydk/w+WgZNUzutUyfC1SqOMU0 KN4w7iQSL+nrCIa2o8mj0xv2Km2CmURpsIPP+vFf5TB9OJM95FGmq9qQZyLJ5IX+IaAt MEBkunA6W4kuGPx+ooRLbJYsTR6IMGeo1lHwFUap5ybzH60YPTBxzcpoH2kER0ZCLSa3 mUQe/zGTgvj0fesXVKNYsyGVXc42KR0D0e6QnO/7pA0e1Bg5tuo36Q3yBx5XQkPFY4sM twtZ1wyPj2pdbxzzUtqcnu49WfAzaMF2+QgVTt0rnnlOigVCzg/J1OHDwcqxzT+pasC2 WQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2h5jm004x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Apr 2018 11:23:20 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w35BNIcl010831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Apr 2018 11:23:18 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w35BNIRg006001; Thu, 5 Apr 2018 11:23:18 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Apr 2018 11:23:18 +0000 Date: Thu, 5 Apr 2018 14:23:11 +0300 From: Dan Carpenter To: Kalle Valo , Amitkumar Karwar Cc: Prameela Rani Garnepudi , Karun Eagalapati , Siva Rebbagondla , linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] rsi: Free the unaligned pointer Message-ID: <20180405112311.GD4218@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8853 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=804 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804050119 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The problem here is that we allocate "data". Then we do "data = PTR_ALIGN(data, 8);" and then we free the aligned pointer and not the one we allocated. I don't know if it causes an issue in real life, but it seems like a reasonable thing to free the same pointer that we allocated. Signed-off-by: Dan Carpenter diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c index d76e69c0beaa..ca4e698ab69b 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c @@ -652,11 +652,11 @@ static int rsi_sdio_load_data_master_write(struct rsi_hw *adapter, static int rsi_sdio_master_reg_read(struct rsi_hw *adapter, u32 addr, u32 *read_buf, u16 size) { - u32 addr_on_bus, *data; + u32 addr_on_bus, *data, *data_orig; u16 ms_addr; int status; - data = kzalloc(RSI_MASTER_REG_BUF_SIZE, GFP_KERNEL); + data = data_orig = kzalloc(RSI_MASTER_REG_BUF_SIZE, GFP_KERNEL); if (!data) return -ENOMEM; @@ -709,7 +709,7 @@ static int rsi_sdio_master_reg_read(struct rsi_hw *adapter, u32 addr, } err: - kfree(data); + kfree(data_orig); return status; } @@ -717,10 +717,10 @@ static int rsi_sdio_master_reg_write(struct rsi_hw *adapter, unsigned long addr, unsigned long data, u16 size) { - unsigned long *data_aligned; + unsigned long *data_aligned, *data_orig; int status; - data_aligned = kzalloc(RSI_MASTER_REG_BUF_SIZE, GFP_KERNEL); + data_aligned = data_orig = kzalloc(RSI_MASTER_REG_BUF_SIZE, GFP_KERNEL); if (!data_aligned) return -ENOMEM; @@ -743,7 +743,7 @@ static int rsi_sdio_master_reg_write(struct rsi_hw *adapter, rsi_dbg(ERR_ZONE, "%s: Unable to set ms word to common reg\n", __func__); - kfree(data_aligned); + kfree(data_orig); return -EIO; } addr = addr & 0xFFFF; @@ -757,7 +757,7 @@ static int rsi_sdio_master_reg_write(struct rsi_hw *adapter, rsi_dbg(ERR_ZONE, "%s: Unable to do AHB reg write\n", __func__); - kfree(data_aligned); + kfree(data_orig); return status; }