From patchwork Tue Dec 18 08:28:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10735127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AE4A13B5 for ; Tue, 18 Dec 2018 08:28:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27BC72A640 for ; Tue, 18 Dec 2018 08:28:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19D3D2A646; Tue, 18 Dec 2018 08:28:25 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC3002A640 for ; Tue, 18 Dec 2018 08:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vQEQH5lHtE8w63s9IEL8JrVeinZyS5Q45EtbH+XChW4=; b=icsPEs673K7ia1 GRSYMtG8zOY6vQYF1DBJuASwIdPUyboihrWfb2eyXGVFW6WLWaYnpQpS3dTH7xw6aqVqxzODK4+K6 W+r1TkUIKCpsKx4HvJK9Nj+nhWkdueCILVmLv9aUWpZE95DPvds6ka3UklxSRzQwnoyGl01hQYyap dPlpm4z7OhKN2b7QAtm6fbmCgWoYWfnbE6udiD9wpgOjUuluX8bJ9q50IC35nKaxvW0jFWVe5xx/3 LR9TcOPu9FwPPKaV/d4dLRK8sDbN1MeicpzIE6oL744LCWU7PiJU+7khvaeS0gLo6C3/rvPCWpu+2 nz9PPvqkfLJgaHm/GsgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZAjn-000467-5x; Tue, 18 Dec 2018 08:28:23 +0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZAjk-00045L-42 for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2018 08:28:21 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBI8S2KZ056768; Tue, 18 Dec 2018 08:28:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=cJcyZ5OFFNli2SRwLuOjdN1N0x2ksq8Cp2LyM1jA1iQ=; b=w2kYeA+9FKCWfqf9iqmZqcLSDFxvUwvKD6d11k4CxsdsBB6kZ6ovuUOWcYbp2AV42tI9 Lu9YPB1h9yfBRruS0EP8iu486acQycqoj7sbHcu5BdnSm4EoCEwg60C8HRfhSQPDNqAZ o/PGceeWYbgkNtYVigUF42P0thtLHS1bE9IkFxroUUWYgiW71VFKPAqIEd3pwCRvynzF rp4QTE1FhoYdKEu41NMioh0TLLNkaizoMzgFQ5wgdOIa4kDlNa/zKfELhkDH0tNltbsC 3Jvc6toBG1zKnpSgtq7gJqtXPoZqlpFJCNrJSgVFbzom6Pz1HKeDIMQ5IOMrsKI5UPaL kA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2pcq4dswmf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 08:28:02 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBI8S05d012766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Dec 2018 08:28:00 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wBI8RxXH007579; Tue, 18 Dec 2018 08:28:00 GMT Received: from kadam (/197.157.0.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 18 Dec 2018 00:27:59 -0800 Date: Tue, 18 Dec 2018 11:28:00 +0300 From: Dan Carpenter To: Maxime Ripard Subject: [PATCH] bus: sunxi-rsb: Fix a small memory leak Message-ID: <20181218082800.GC440@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9110 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812180075 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181218_002820_249259_91A2561F X-CRM114-Status: GOOD ( 17.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen-Yu Tsai , kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The problem is in __devm_regmap_init_sunxi_rsb(). If the call to __devm_regmap_init() fails, then we leak the "ctx" allocation. Signed-off-by: Dan Carpenter --- drivers/bus/sunxi-rsb.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 1b76d9585902..5ec25c8164d1 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -417,17 +417,9 @@ static int regmap_sunxi_rsb_reg_write(void *context, unsigned int reg, return sunxi_rsb_write(rdev->rsb, rdev->rtaddr, reg, &val, ctx->size); } -static void regmap_sunxi_rsb_free_ctx(void *context) -{ - struct sunxi_rsb_ctx *ctx = context; - - kfree(ctx); -} - static struct regmap_bus regmap_sunxi_rsb = { .reg_write = regmap_sunxi_rsb_reg_write, .reg_read = regmap_sunxi_rsb_reg_read, - .free_context = regmap_sunxi_rsb_free_ctx, .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, .val_format_endian_default = REGMAP_ENDIAN_NATIVE, }; @@ -446,7 +438,7 @@ static struct sunxi_rsb_ctx *regmap_sunxi_rsb_init_ctx(struct sunxi_rsb_device * return ERR_PTR(-EINVAL); } - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = devm_kzalloc(&rdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return ERR_PTR(-ENOMEM);