From patchwork Sat Mar 29 07:03:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3908181 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E573BF540 for ; Sat, 29 Mar 2014 07:03:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C68E20304 for ; Sat, 29 Mar 2014 07:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B20BE20340 for ; Sat, 29 Mar 2014 07:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750910AbaC2HDo (ORCPT ); Sat, 29 Mar 2014 03:03:44 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:65157 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbaC2HDo (ORCPT ); Sat, 29 Mar 2014 03:03:44 -0400 Received: by mail-pd0-f175.google.com with SMTP id x10so5784034pdj.20 for ; Sat, 29 Mar 2014 00:03:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=hSTTc93mmhRfWqrgxQkjG/bwwynZZng4vL8fagqhVLU=; b=L6CFLkaFGPl/Kef6+rxtCvotARSLXzViaCmGEi0MGI9aWzifRD2/Pa2YjaHjaayB3w 5SBJXptt8GaHz4wpuQqqlTPlPtBYRoN2fuYvVaghb0Q9Bhv1PPD/+4WqXdEIwkt+PkQ2 wyaJWL5pgweZo6v8c6xiFbKvZ0UyJIBc+9WweKl41qDd7vkl7GKUUo6zuEBV3pNyPr5+ w8381fVW6yYbJFO2dj6N61OSwUOokC/SbeOYxe0x0zj1gSmRhbppr93fhOMw6v1WntXN A9GLm8hqa8ZuT6ToFL6W2lWsRctGL0c1Lx3ktLu7fe5g4LEYgluVOyAZpakM3AJr5SZb bd9Q== X-Gm-Message-State: ALoCoQld55adJJnVUOQk1yYvlEe9b9NSro5N/uwnS80lF+YckJVpbhFFfuVfLzq3Nzjshy3lvWGB X-Received: by 10.66.26.81 with SMTP id j17mr12863383pag.87.1396076623656; Sat, 29 Mar 2014 00:03:43 -0700 (PDT) Received: from [192.168.0.119] (59-115-21-222.dynamic.hinet.net. [59.115.21.222]) by mx.google.com with ESMTPSA id tu3sm7167251pab.1.2014.03.29.00.03.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 29 Mar 2014 00:03:42 -0700 (PDT) Message-ID: <1396076617.1937.1.camel@phoenix> Subject: [PATCH] spi: omap-100k: Fix memory leak From: Axel Lin To: Mark Brown Cc: Fabrice Crohas , linux-spi@vger.kernel.org Date: Sat, 29 Mar 2014 15:03:37 +0800 X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memory allocated for cs is not freed anywhere. Convert to use devm_kzalloc to fix the memory leak. Signed-off-by: Axel Lin --- drivers/spi/spi-omap-100k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c index c9e2282..e7ffcde 100644 --- a/drivers/spi/spi-omap-100k.c +++ b/drivers/spi/spi-omap-100k.c @@ -283,7 +283,7 @@ static int omap1_spi100k_setup(struct spi_device *spi) spi100k = spi_master_get_devdata(spi->master); if (!cs) { - cs = kzalloc(sizeof(*cs), GFP_KERNEL); + cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; cs->base = spi100k->base + spi->chip_select * 0x14;