From patchwork Thu Apr 21 16:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 1620269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KkjDb1Wv4z9s75 for ; Fri, 22 Apr 2022 02:10:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KkjDZ44dGz3bWG for ; Fri, 22 Apr 2022 02:10:06 +1000 (AEST) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=wanadoo.fr (client-ip=80.12.242.130; helo=smtp.smtpout.orange.fr; envelope-from=christophe.jaillet@wanadoo.fr; receiver=) Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KkjDR3DNCz2x9J for ; Fri, 22 Apr 2022 02:09:56 +1000 (AEST) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id hZG5nf9FJ8sSvhZG5n3O1L; Thu, 21 Apr 2022 18:02:21 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 21 Apr 2022 18:02:21 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: Jeremy Kerr , Joel Stanley , Alistar Popple , Eddie James Subject: [PATCH] fsi: Fix error handling in fsi_master_register() and its callers Date: Thu, 21 Apr 2022 18:02:15 +0200 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe JAILLET , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" fsi_master_register() calls device_register(). When device_register() fails, put_device() still needs to be called. Up to now, there is no put_device() in fsi_master_register(). Some callers of fsi_master_register() have it, some have not. - fsi_master_acf_probe() call put_device() if fsi_master_register() fails - fsi_master_gpio_probe() call put_device() if fsi_master_register() fails - fsi_master_aspeed_probe() doesn't - hub_master_probe() doesn't In order to fix it and be consistent with the different callers, add the missing put_device() in the error handling path of fsi_master_register() and remove it from 2 callers that were handling it by themselves. Signed-off-by: Christophe JAILLET --- This patch is speculative and compile tested only. Review with care. Another alternative would be to add the put_device() call in fsi_master_aspeed_probe() and hub_master_probe() if it makes more sense. Having one or more Fixes tag is a bit hard because of the relations and log history of the 5 files involved in this bug fix. --- drivers/fsi/fsi-core.c | 1 + drivers/fsi/fsi-master-ast-cf.c | 1 - drivers/fsi/fsi-master-gpio.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 3a7b78e36701..640692e5400f 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1319,6 +1319,7 @@ int fsi_master_register(struct fsi_master *master) rc = device_register(&master->dev); if (rc) { + put_device(&master->dev); ida_simple_remove(&master_ida, master->idx); return rc; } diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c index 24292acdbaf8..dde63d703ea1 100644 --- a/drivers/fsi/fsi-master-ast-cf.c +++ b/drivers/fsi/fsi-master-ast-cf.c @@ -1395,7 +1395,6 @@ static int fsi_master_acf_probe(struct platform_device *pdev) return 0; device_remove_file(master->dev, &dev_attr_external_mode); - put_device(&master->master.dev); return rc; stop_copro: diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index 7d5f29b4b595..1ae3c164d7fd 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -856,7 +856,6 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) rc = fsi_master_register(&master->master); if (rc) { device_remove_file(&pdev->dev, &dev_attr_external_mode); - put_device(&master->master.dev); return rc; } return 0;