From patchwork Thu Dec 26 07:00:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 3406091 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7CFB19F314 for ; Thu, 26 Dec 2013 07:02:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B24C62015E for ; Thu, 26 Dec 2013 07:02:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B6802015A for ; Thu, 26 Dec 2013 07:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127Ab3LZHCc (ORCPT ); Thu, 26 Dec 2013 02:02:32 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:38750 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220Ab3LZHCc (ORCPT ); Thu, 26 Dec 2013 02:02:32 -0500 Received: from tarshish.tkos.co.il (80.179.12.157.static.012.net.il [80.179.12.157]) by mx.tkos.co.il (Postfix) with ESMTPA id DB55E440A97; Thu, 26 Dec 2013 09:02:29 +0200 (IST) From: Baruch Siach To: Mark Brown Cc: linux-spi@vger.kernel.org, Feng Tang , Jean-Hugues Deschenes , Baruch Siach Subject: [PATCH 3/4] spi: dw: fix memory leak on error path Date: Thu, 26 Dec 2013 09:00:14 +0200 Message-Id: <4ed40da8c93766ac05ee8d3507ae1d9fdc0a68a7.1388040447.git.baruch@tkos.co.il> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: References: 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.5 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 Cc: Feng Tang Signed-off-by: Baruch Siach --- drivers/spi/spi-dw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index e37dfc1..c3354e8 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -616,6 +616,7 @@ static int dw_spi_setup(struct spi_device *spi) { struct dw_spi_chip *chip_info = NULL; struct chip_data *chip; + int ret; /* Only alloc on first setup */ chip = spi_get_ctldata(spi); @@ -656,7 +657,8 @@ static int dw_spi_setup(struct spi_device *spi) if (!spi->max_speed_hz) { dev_err(&spi->dev, "No max speed HZ parameter\n"); - return -EINVAL; + ret = -EINVAL; + goto err_kfree; } chip->speed_hz = spi->max_speed_hz; @@ -669,6 +671,11 @@ static int dw_spi_setup(struct spi_device *spi) spi_set_ctldata(spi, chip); return 0; + +err_kfree: + kfree(chip); + + return ret; } static void dw_spi_cleanup(struct spi_device *spi)