Received: by 2002:a05:6520:2586:b029:fa:41f3:c225 with SMTP id u6csp865190lky; Thu, 10 Jun 2021 12:57:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOiln8/dhXrhFCkgMOP8Fq636vbYq7tqkBBV+zBY8a9dvypx7+XwlAU4Rt3xfpjdcGkBDj X-Received: by 2002:a17:906:b748:: with SMTP id fx8mr247541ejb.477.1623355049435; Thu, 10 Jun 2021 12:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623355049; cv=none; d=google.com; s=arc-20160816; b=eNcITjlnBhz8NAR2y1K8/dvQZeLjrML/kclKDfaIDgGiTHPWNDFkJLXtMkSfBTFQb9 Keu4XoEi2z4iJ/V5UU9HBdVDvQ1FZUwVEn4kQMOzwMjdR9WJAyJk9f25TwLS1aR2hhKB 6HATRZaRAfSWaqiV6Y3kYXho2hFsKaJeV8l1YIk1reR3bSvfypK9XhBKMWOceYT7NK3g 069nIULZUiDcYtTArfC0lhnMRKVdcYcCSbliuUk/5zLr7e59CD1QO79zRNs/2soynayy jIvNsQ1E6ZB1gPH8H5AMpfeLKvzGfFr59euhYYFuAuA7O64IkX4fcFC4ks/4+LMTHsHR I6CA== 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 :message-id:date:subject:cc:to:from; bh=u3vyMkaRHjTa+TIkuDw7AVUJBYJWXcsS9eROik0Fa38=; b=kwMH5ZZRuhfBjyRiP+7nVRb5O2WhyL6eJihkDIx5CutedIKAvVVU5XHfIvq0IH0P4A W0iTcT7mr9YvjIukH7DmFENX7zXXLwlYEbrWTkB1reQJhUnV3b+Hwh3z9p0XKyxLQHsu YtLe8MKfHRwAj3r71zs0y5nrrlpeVB6+pX2bXPoZxbodK+uTD6GnrDVPz6zt0Ucp3zfy qWa3sKZQNlgQkzyRzOmlTa5sogn1bYQHgLys9rX3uRqutZPhojUqnKIR26jB/HKpu0a5 ZIvVFxRyUklQQx4x2Oo3GnTTm0jCsoG1cQ2Ykd60klqtmahIfkdDvShug6iggpzS4IVQ A8gw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf2si3525973ejb.500.2021.06.10.12.57.04; Thu, 10 Jun 2021 12:57:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbhFJT4d (ORCPT + 99 others); Thu, 10 Jun 2021 15:56:33 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:33534 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230130AbhFJT4c (ORCPT ); Thu, 10 Jun 2021 15:56:32 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d69 with ME id FXuX2500721Fzsu03XuYBA; Thu, 10 Jun 2021 21:54:33 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 10 Jun 2021 21:54:33 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: Yasunari.Takiguchi@sony.com, mchehab@kernel.org, narmstrong@baylibre.com, sean@mess.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2] media: cxd2880-spi: Fix an error handling path Date: Thu, 10 Jun 2021 21:54:31 +0200 Message-Id: <40b114d7200d2a87150249f8228b88f7a4ee15e0.1621599392.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs after a successful 'regulator_enable()' call, 'regulator_disable()' must be called. Fix the error handling path of the probe accordingly. Fixes: cb496cd472af ("media: cxd2880-spi: Add optional vcc regulator") Signed-off-by: Christophe JAILLET --- v2: In case of error 'dvb_spi->vcc_supply' is set to NULL So test for NULL instead of IS_ERR as spotted by Sean Young v1 was part of a small serie. Patch 2/2 has been applied, so this update is now sent as a single patch --- drivers/media/spi/cxd2880-spi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c index 931ec0727cd3..df1335e7061c 100644 --- a/drivers/media/spi/cxd2880-spi.c +++ b/drivers/media/spi/cxd2880-spi.c @@ -524,13 +524,13 @@ cxd2880_spi_probe(struct spi_device *spi) if (IS_ERR(dvb_spi->vcc_supply)) { if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto fail_adapter; + goto fail_regulator; } dvb_spi->vcc_supply = NULL; } else { ret = regulator_enable(dvb_spi->vcc_supply); if (ret) - goto fail_adapter; + goto fail_regulator; } dvb_spi->spi = spi; @@ -618,6 +618,9 @@ cxd2880_spi_probe(struct spi_device *spi) fail_attach: dvb_unregister_adapter(&dvb_spi->adapter); fail_adapter: + if (!dvb_spi->vcc_supply) + regulator_disable(dvb_spi->vcc_supply); +fail_regulator: kfree(dvb_spi); return ret; } -- 2.30.2