From patchwork Thu Apr 26 07:31:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10364833 X-Patchwork-Delegate: johannes@sipsolutions.net 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 885C660225 for ; Thu, 26 Apr 2018 07:34:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7665D2906E for ; Thu, 26 Apr 2018 07:34:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69CA129071; Thu, 26 Apr 2018 07:34:08 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable 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 F38952906E for ; Thu, 26 Apr 2018 07:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754084AbeDZHdw (ORCPT ); Thu, 26 Apr 2018 03:33:52 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34308 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465AbeDZHdu (ORCPT ); Thu, 26 Apr 2018 03:33:50 -0400 Received: by mail-lf0-f66.google.com with SMTP id h4-v6so2418763lfc.1; Thu, 26 Apr 2018 00:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=h4nwRfeoOiKElNVb7xTegm0XGSubyIyTKRy0orGNaU4=; b=k60LSTQ0p2egKT2u93wxcuy7k2FaGNJPFVL5sk3i0U2SZ22YeesCfMoOVS7ymHCON/ 8qRIX4U+vgQDIEArqFuBsvrNdQnNuKolG/r8EanVii2ivYJmtINjOpc06OeLRh/hGSFT wu9RlnEKBoTxAttVLokfv/mf97LK6H5EEiUyCAx4JN4eQLVoq1VkuRdY6l1EQ3HuLstM feIc8RMym4/YLfR1kFTb8qLV7urJjr8weQFoKPSXvTeaWa39fE/w/R32GbR8xtsLFyWY /03BHGoIMP4oVvytHPpqRPJCc56Zu1B7sK1B4V9Pj98kW/Wb4KMwWJnCCiJnDmaPcmGB 7sZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=h4nwRfeoOiKElNVb7xTegm0XGSubyIyTKRy0orGNaU4=; b=Ce4B4dXsrOAjalxB2Sry7cXC+uKXI3jl7k2ya3Or52uLhMh77VtKkdQUhdyv2vtBSr 3rutY8RACb/So5dLFzBOhcLyQG5KeU84BLy7EcRuPgIad1MgJlJhQxsRORLN97oOtOFp ialh9caZClYlUK6hGfwoxZMMV1hJp3G3GYv+LOQZACjNkvmOBG/bTLg1K3h0y+A08nho ll75DBa++8Mcbv56DeyrgDtuUExMaqzYlywUJvC2tsbXZ5379GUnUVgp0AgxbnuvUlTr Rv38kPjsrMQPf7ueN+KZtX6q6t8OPUsrjUsFPyrxOFpidP1qnBWJAzOXszPkiNHl6Vn3 6fwg== X-Gm-Message-State: ALQs6tBtqLS0RZOgYQwdaETigUn2HzKhjh8HAIyzXJMcSe7Tb5vD+MVV /LDr5oYBADcbuotaBmdg1q8= X-Google-Smtp-Source: AB8JxZp5KNRM00fsBn4WW59MVxlqM9H+7t1JU2KknLsUmBZSC3SxOvkjyKCS2uM/GxU0TxrApvFJbA== X-Received: by 2002:a19:95c2:: with SMTP id x185-v6mr3919385lfd.74.1524728028112; Thu, 26 Apr 2018 00:33:48 -0700 (PDT) Received: from xi.terra (c-8bb2e655.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.230.178.139]) by smtp.gmail.com with ESMTPSA id i62-v6sm1568013lfa.22.2018.04.26.00.33.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 00:33:47 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.90_1) (envelope-from ) id 1fBbPQ-000268-IJ; Thu, 26 Apr 2018 09:33:40 +0200 From: Johan Hovold To: Johannes Berg Cc: "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Heikki Krogerus Subject: [PATCH] net: rfkill: gpio: fix memory leak in probe error path Date: Thu, 26 Apr 2018 09:31:52 +0200 Message-Id: <20180426073152.7953-1-johan@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to free the rfkill device in case registration fails during probe. Fixes: 5e7ca3937fbe ("net: rfkill: gpio: convert to resource managed allocation") Cc: stable # 3.13 Cc: Heikki Krogerus Signed-off-by: Johan Hovold Reviewed-by: Heikki Krogerus --- net/rfkill/rfkill-gpio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index 41bd496531d4..00192a996be0 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c @@ -137,13 +137,18 @@ static int rfkill_gpio_probe(struct platform_device *pdev) ret = rfkill_register(rfkill->rfkill_dev); if (ret < 0) - return ret; + goto err_destroy; platform_set_drvdata(pdev, rfkill); dev_info(&pdev->dev, "%s device registered.\n", rfkill->name); return 0; + +err_destroy: + rfkill_destroy(rfkill->rfkill_dev); + + return ret; } static int rfkill_gpio_remove(struct platform_device *pdev)