From patchwork Tue Jun 20 09:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9799011 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 99BC660329 for ; Tue, 20 Jun 2017 09:35:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EDD81FFCA for ; Tue, 20 Jun 2017 09:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 833DF27DCD; Tue, 20 Jun 2017 09:35:24 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2914E1FFCA for ; Tue, 20 Jun 2017 09:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752408AbdFTJdA (ORCPT ); Tue, 20 Jun 2017 05:33:00 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:32884 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbdFTJbd (ORCPT ); Tue, 20 Jun 2017 05:31:33 -0400 Received: by mail-pf0-f196.google.com with SMTP id w12so21655099pfk.0; Tue, 20 Jun 2017 02:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=eHPz6Pdbn/3Pm9vqvADy6IZiCt7By0zVMPibW3so6w0=; b=EPvUb1nOOebGYUyFksjyZfeAnlzob6uU/O2GkgHeLSMdlBIvurSwO4VJch4nFPQU6b XH5WBWmsv+uS8/mm/Q9XtoiSaVeAUvB0PQZlGd8g1JwYkaZSzwshSWH7PC4Bh7oWNI7J CwvRdArl0ywcCvJIxJtXd1JjCikx0f5LhhoxNBlgxuGCCvmq4+uC5vIKC+WL1wKtWhvV LsPMqx5oWJOEggPVE+us/Ab0VL8rcpbsFN3uMELSP355s9erWOoeIgi5Qy/lQLwq2Rde fQpxy0tPPN++GyUn73qoa0Mt4o3OxjtCidCGZg6pY2NfiqJoxg31vpOvvN+yE8N1v6WS oZ0A== 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=eHPz6Pdbn/3Pm9vqvADy6IZiCt7By0zVMPibW3so6w0=; b=npdWCVNeso3ev4c3pqkioLeLMQCLui+/JgfDqVFDdYcrESpkVJBpLejh50pERGF+Ju REPxWGMNNLWRd/UUaT24mbahEYfJLOUTxkAhKONltG4Kxm9l6Uk3joT2CFEHrk0i3XRg quKbwQzyLKdKNL3pSrM0uf0X/ZaKSp0gh/E28pPXMRoVlC2uTH42A8cPiBbAXsFMF3eP whfm/urtHQ5AXlJl3fD2nWCOlLzUTU0GXdLYxW08LlWFlqQCr5lnaVEt7rnC5pmgaVHM EaVDKj03L6zsTB+GX9iU2PfWHbErRhK4jz6IXFlYQJ28Rth0eM6MYtey2LdkraLl9ZTw Yqjg== X-Gm-Message-State: AKS2vOxvgaF6eOwMbF5y/wo1dYcicC7hBeIbIImXP/HBGgPfWCad0CY0 f94StXEYS2ot4w== X-Received: by 10.98.31.10 with SMTP id f10mr29862165pff.164.1497951091527; Tue, 20 Jun 2017 02:31:31 -0700 (PDT) Received: from symbol-HP-Z420-Workstation.zebra.lan ([223.31.70.102]) by smtp.googlemail.com with ESMTPSA id a28sm25816542pfl.25.2017.06.20.02.31.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 02:31:30 -0700 (PDT) From: Arvind Yadav To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: loopback-test: Fix kfree() NULL pointer error. Date: Tue, 20 Jun 2017 15:00:53 +0530 Message-Id: <36969f0624050d0ca6262e79bf4935698d063d84.1497950982.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Here, rx/tx allocation can fail. So avoid kvfree call with NULL pointer. Signed-off-by: Arvind Yadav --- drivers/spi/spi-loopback-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index f4875f1..e459d01 100644 --- a/drivers/spi/spi-loopback-test.c +++ b/drivers/spi/spi-loopback-test.c @@ -1021,10 +1021,9 @@ int spi_test_run_tests(struct spi_device *spi, rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); else rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); - if (!rx) { - ret = -ENOMEM; - goto out; - } + if (!rx) + return -ENOMEM; + if (use_vmalloc) tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); @@ -1032,7 +1031,7 @@ int spi_test_run_tests(struct spi_device *spi, tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); if (!tx) { ret = -ENOMEM; - goto out; + goto err_tx; } /* now run the individual tests in the table */ @@ -1057,8 +1056,9 @@ int spi_test_run_tests(struct spi_device *spi, } out: - kvfree(rx); kvfree(tx); +err_tx: + kvfree(rx); return ret; } EXPORT_SYMBOL_GPL(spi_test_run_tests);