Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp534334ybl; Thu, 15 Aug 2019 23:24:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjckBq1l2bGWkMsMuMUS3vC2BSmCoBIY7m61z9XcpsCp9psFn2oIMsw4ud8lF+a2B8GjJ0 X-Received: by 2002:a62:7a0f:: with SMTP id v15mr9184117pfc.35.1565936680553; Thu, 15 Aug 2019 23:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565936680; cv=none; d=google.com; s=arc-20160816; b=hxDUztHYm5dK6LMZd3+3wlWAmj2Tvm6DKwvD6JtO6xXRyKaU454LO2CxAGpwLCKNbe 01xk/z39HqUaJhUppboqdA+h4qFuBVkQ7EMrz6ehBVkLj38TPNiDEftSj0ev/Ru1EHYi VZ0BtwUDRgM4VT8i0lfU4F9evOH6sV2EGaMjm2Rb3VmEDnZLYr3I70Wts959FAq4Jjmj aIqdcm4L/Nw/p9kNV5b9GssvelUWo2PKdTHcmqmWXEF9WmM/U3vrL2ufF5ysuE2uEqGe 0oEavfYZaj9TMYHol8knmJJP2PXLQ27Ii0SW1xSzG00FIjphx0nswl5i2WcVnTvyPmLf 4ltw== 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=kdbxFDHYGClUoNsZGKKPkP7v5sij1u1AQCARlCPuJqQ=; b=cG7Zz0TtnVtiPoN7kGqoYP+/E4Jk+4nZ0rGpvvaDtMbY7EnBcZ9yijGZU/OlpHFqay MuuZohNvQbcipFT4haSPSystb/evExibotEsmOoIh84yTnVWhf0eNIOLOGmsyaXDQZqx rzrMXriOoHgPmkZ4D3F4gKyuOh8YIPrmTUpACqyzTuR/M/pxfKSRBLhlDe33nIqkh87d AI0ac2X14o39ZesbfdkVW3y8i07hDQJ+PlVsVNubGhELFVr3/G7rC+apUVk6qKqrhI6L QGHxtxDxLkOktOPJSPs+B96BGtHWLFEbA80Yrta77wGnZZ9vSPDO9sH5IszgwCtC3HDL If9g== 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 f196si3791115pfa.57.2019.08.15.23.24.24; Thu, 15 Aug 2019 23:24:40 -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 S1726767AbfHPGXn (ORCPT + 99 others); Fri, 16 Aug 2019 02:23:43 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:44236 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHPGXm (ORCPT ); Fri, 16 Aug 2019 02:23:42 -0400 Received: by mail-yw1-f65.google.com with SMTP id l79so1459063ywe.11; Thu, 15 Aug 2019 23:23:42 -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=kdbxFDHYGClUoNsZGKKPkP7v5sij1u1AQCARlCPuJqQ=; b=LbEPwmQELKI6lVvU5HXRMNCTD97aRYptdnIL5tWhGaFE3Ty4MljhgarlTjiqenA6R6 j6blhWUa1VCtHpucFvdTcEvufym5+sKQIMfvCixRhIFrfApj79DcdK6z0OvV1jsye/Sq mB0vDXPM/3oqIb9eSAxHULytAtTktZkKPCUE6v4Ye8cjCwcJcAYWRhvNfyER1CUx1A81 XWkdG7o/m+1/TwDF8r/nb4FVmwODbq1x8f0w/uxGMjQn8vGNAgWoC3r6+ENm0Kz0lR1i +KGSIgyDlGb+2IIsrcSlVTHw8D+VGSP4rbhDDmzwQN7aHpmsLcAQxPTyjm0TQgDGJI4D gdtQ== X-Gm-Message-State: APjAAAXGauqwHA6ih05oQ+yA+jamOYb2eTfwD3YSzsAV51hg7pmpyTIX OQU8iuT8ukueVlgz/Xv/cZo= X-Received: by 2002:a81:4bc5:: with SMTP id y188mr5444262ywa.177.1565936621994; Thu, 15 Aug 2019 23:23:41 -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 g68sm1102026ywb.87.2019.08.15.23.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Aug 2019 23:23:40 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Dan Williams , Vinod Koul , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Kate Stewart , dmaengine@vger.kernel.org (open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] dmaengine: ti: Fix a memory leak bug Date: Fri, 16 Aug 2019 01:23:21 -0500 Message-Id: <1565936603-7046-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 ti_dra7_xbar_probe(), 'rsv_events' is allocated through kcalloc(). Then of_property_read_u32_array() is invoked to search for the property. However, if this process fails, 'rsv_events' is not deallocated, leading to a memory leak bug. To fix this issue, free 'rsv_events' before returning the error. Signed-off-by: Wenwen Wang --- drivers/dma/ti/dma-crossbar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/ti/dma-crossbar.c b/drivers/dma/ti/dma-crossbar.c index ad2f0a4..f255056 100644 --- a/drivers/dma/ti/dma-crossbar.c +++ b/drivers/dma/ti/dma-crossbar.c @@ -391,8 +391,10 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev) ret = of_property_read_u32_array(node, pname, (u32 *)rsv_events, nelm * 2); - if (ret) + if (ret) { + kfree(rsv_events); return ret; + } for (i = 0; i < nelm; i++) { ti_dra7_xbar_reserve(rsv_events[i][0], rsv_events[i][1], -- 2.7.4