Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2354152pxb; Mon, 20 Sep 2021 19:53:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD86iSctkEkdYdDBowaauKBLBj6+uCjsZjJMJnAP33+FIvKsm/nGlS3OAI8dhbZY3c18XQ X-Received: by 2002:a05:6e02:1d86:: with SMTP id h6mr17576883ila.5.1632192796730; Mon, 20 Sep 2021 19:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192796; cv=none; d=google.com; s=arc-20160816; b=CkMfpInjULR7ow+SaBO7je4q4pv3QctjQReD6mKhTvVtP2rg6q4397T992rOIEsxr2 D0tWqfUUpY7DKsDiVB/o0Z8dtNv85QT1Z6A47EPX62PBI/3mpTRzxT3ZO5K26t4EYv3T 8kue7nAGc8T2kjAb9SmfJKvH2d31Kq1wqGC+EaUuYmBIKAIEsymx/pKUhUFbH8RL1nXX bDFX+usanRNGm49FRG2RGajboLLi9w6/MQ0ddnVRMUDkDwEtcvpVdYWn5AQee3ZM3FY9 u+3oQF17EjuDsz+D0iw6vMKi2zNxyjZYs2F4uPgYoECK49oRP2nCVjZj1Q9Ob9pPU/Lf 0uEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RiMk1pNut0NE6Q8ATU7FpAI3uPwtdJ1bn810Wwo4Fe8=; b=y0ooyuF/YopgKOcumodk0DBvrRXaKModwoZyUCZ7gnUNLmZkE4OzRCOmwBAGXfnVxA gt5HAzNoe2nKWHWe0QQzmU/b2LQYFP198FFvFnq2qcgZbXbrtmd38XcOQNgLoEVnaKyw WxFq3l+6M6GjieZDtMk/xQE54D6SR7l6oZTpuOb9zELh7SqCBreW34HBEZve7gUPxFMy qoN1nR7xhNBZlRvTrco6lbpj6mT9w6p79T79OYi17wqidNT9KW3a/sxEhwq/rN4Hrz93 6wXC1wW7j4tuZIs1tuPRrIhodos80vlDYKABFsRM4Uo0Ngk3/JPfpZ2ZZitUVmQ08Z5U +wZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EEE69CA1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si14252435ile.86.2021.09.20.19.53.05; Mon, 20 Sep 2021 19:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EEE69CA1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386049AbhITS6c (ORCPT + 99 others); Mon, 20 Sep 2021 14:58:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384612AbhITSs3 (ORCPT ); Mon, 20 Sep 2021 14:48:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16E986337D; Mon, 20 Sep 2021 17:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159248; bh=p+ZZn61JJA25b2nR8Jk9ZR27Knm7fkfpCZzlGmUg5Vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EEE69CA1VcJUfW6eGysmWUZwiVcsIbCcmX0NvgDzJIDAKS0RCrR3Hq/HMB4znY99X EsBMceE6CiMdCXYVp51niAPZgD+3udlasdcdOAHxb8wwPmFn9iRy04h9Dmli2W06D2 HcHPzWiIH3IDDEKXA2f6HX/IzbDKqFOOO2Aea8U8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.14 145/168] gpio: mpc8xxx: Use devm_gpiochip_add_data() to simplify the code and avoid a leak Date: Mon, 20 Sep 2021 18:44:43 +0200 Message-Id: <20210920163926.422367515@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit 889a1b3f35db6ba5ba6a0c23a3a55594570b6a17 ] If an error occurs after a 'gpiochip_add_data()' call it must be undone by a corresponding 'gpiochip_remove()' as already done in the remove function. To simplify the code a fix a leak in the error handling path of the probe, use the managed version instead (i.e. 'devm_gpiochip_add_data()') Fixes: 698b8eeaed72 ("gpio/mpc8xxx: change irq handler from chained to normal") Signed-off-by: Christophe JAILLET Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-mpc8xxx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index fdb22c2e1085..d574e8cb6d7c 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -380,7 +380,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) is_acpi_node(fwnode)) gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff); - ret = gpiochip_add_data(gc, mpc8xxx_gc); + ret = devm_gpiochip_add_data(&pdev->dev, gc, mpc8xxx_gc); if (ret) { dev_err(&pdev->dev, "GPIO chip registration failed with status %d\n", ret); @@ -429,8 +429,6 @@ static int mpc8xxx_remove(struct platform_device *pdev) irq_domain_remove(mpc8xxx_gc->irq); } - gpiochip_remove(&mpc8xxx_gc->gc); - return 0; } -- 2.30.2