Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp424391ybl; Thu, 15 Aug 2019 20:51:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFAqkUN0EAC+Yu3+CG6F4+tsF7euxnVIYfdwmrfegJSHnWYEbuXPJuDUD2sOiog93ntQMn X-Received: by 2002:a17:90a:9505:: with SMTP id t5mr5209116pjo.96.1565927466944; Thu, 15 Aug 2019 20:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565927466; cv=none; d=google.com; s=arc-20160816; b=rSxUqU6ujAWY88fsIvKi3iCtGsI1ip++G4NY5b1rs2JSVvjSI7IJPILsFMkYqZ/puU Pp8LTj171vCWqMiBOuV+xpanli7ktXM69RNG/2yy3ax6ToAoUy3q+lfA6aa6QNrZZO3m SdipPvEU35LGh0s0iY1s2xbKazTuHjChYKlRVzpDRO/ohUhOII/5l4S33PuNB4NHtetS 3Rwp8kRWJyxDiKSDfZQYVQObGIdSvrOBr613H6IKkmfdLVUBA15b/8Sx5ZPP2wJf07zY VNnUzlV24sh+50ULoQAA4MNaN0NyWbpg2LbNUkOJXZ82OhU8jBJzGTj+AN3W00RghZV2 vEQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=HlyAjF59EodmIyM3qXcajR4GZniJoos5543aYOc+XW0=; b=CgzHDReKMWuO7N1yTdZ7ZxezS3KeeQPFSNc0L+zgxQOiMJy88r30Kdeedrn5v46rID /ZRTqp93h2p3yWM3OLEWjzlsrZCP/1jH5TbL3uxhsSM1G2HI+0KlWPUN12oj5Y4af55o GFBg3x7dQHOvOl+EVrc29idOlpH7qzmRAaS0Y6sZK8O6zX/B4Jp5AlBJvFR1F9m4FKcb hFIECdwOo1HWhxjI/fLn05wBqzPCH98awSZZhUFtyCx33KVD7lWBoL+wiJpn4mUnk6Is GRPmCO5ujrJcuccHWjVb2JvAFRzLFWHaW9BQFBQLFGtHtKdi9rsUAL5A/b7J+zA2OZ9r eHeA== ARC-Authentication-Results: i=1; mx.google.com; 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 k98si2185456pje.41.2019.08.15.20.50.50; Thu, 15 Aug 2019 20:51:06 -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; 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 S1726606AbfHPDuQ (ORCPT + 99 others); Thu, 15 Aug 2019 23:50:16 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:41932 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbfHPDuP (ORCPT ); Thu, 15 Aug 2019 23:50:15 -0400 Received: by mail-yb1-f194.google.com with SMTP id n7so1538332ybd.8; Thu, 15 Aug 2019 20:50:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HlyAjF59EodmIyM3qXcajR4GZniJoos5543aYOc+XW0=; b=btQj5AZ56dAs1ICKoWFSkZerkAWsY8DDUKdBSxAbKI5xEzlgG+1GSPdJoVh65IT6iT CKcjMP3p/BH3MzhEaNDMVCKbpxzGDF1HX8FfEyVs05uu/go8iYXxL4u2HYj5LWffBZHO qUdPqktDv7yZJbv00eGKeyzoQMTqAkeFg0ZgBZ1tWBHbYF6Yll7OFtxqSLMUQPDK9nLM wzOfGJYv22pYWO7Gkr5vTyrqxK/DTXKvfV5AiLWamJkUcBMEsi2NE0dQ/uBW4AuRU/Ti oM9wpiNBOfI1WB+3pI3OWsZgW/XFITMJYFs1b9tFIx57n/DboM48VgpqzoMA0Vz46JM2 PrZg== X-Gm-Message-State: APjAAAVfNiy5YGrm2GG74qE+1cHCKyR7tmOugZhZq3T8vTgCwjC48R3O 75DrskCwrJpuw4KTonQtntM= X-Received: by 2002:a25:b325:: with SMTP id l37mr5673202ybj.197.1565927414973; Thu, 15 Aug 2019 20:50:14 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id s188sm1066662ywd.7.2019.08.15.20.50.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 20:50:13 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Kalle Valo , "David S. Miller" , Herbert Xu , Dan Carpenter , Eric Biggers , Ard Biesheuvel , linux-wireless@vger.kernel.org (open list:NETWORKING DRIVERS (WIRELESS)), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] airo: fix memory leaks Date: Thu, 15 Aug 2019 22:50:02 -0500 Message-Id: <1565927404-4755-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In proc_BSSList_open(), 'file->private_data' is allocated through kzalloc() and 'data->rbuffer' is allocated through kmalloc(). In the following execution, if an error occurs, they are not deallocated, leading to memory leaks. To fix this issue, free the allocated memory regions before returning the error. Signed-off-by: Wenwen Wang --- drivers/net/wireless/cisco/airo.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 9342ffb..f43c065 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -5441,11 +5441,18 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { Cmd cmd; Resp rsp; - if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; + if (ai->flags & FLAG_RADIO_MASK) { + kfree(data->rbuffer); + kfree(file->private_data); + return -ENETDOWN; + } memset(&cmd, 0, sizeof(cmd)); cmd.cmd=CMD_LISTBSS; - if (down_interruptible(&ai->sem)) + if (down_interruptible(&ai->sem)) { + kfree(data->rbuffer); + kfree(file->private_data); return -ERESTARTSYS; + } issuecommand(ai, &cmd, &rsp); up(&ai->sem); data->readlen = 0; -- 2.7.4