From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C96239A7E0 for ; Wed, 1 Jul 2026 22:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782943469; cv=none; b=MEi4HjQyP+5mdLOHdpJUlRp29SjuUvMd5kDkiQ8n9/U4nEQJlDVVy2DO4A1rqEiIkOK2TniIl3b4Tw4MyIFK/RVKmH58QgWiWl3xaCxkDyLvYrAmimuPj0qUir+C41Ex9J44PNGoajVW0RfNA38RGkr4SlPJ/Q2a7U+oiznVTt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782943469; c=relaxed/simple; bh=B1WbpDMmrPYUWp6KOr4vzYkYkI+6NxB8AKyu4OAt2mg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pbfAzZL1Y3jsB5fUgjbLiBE2rVqGc8djdRj3xQJgFwiIKiJ865qlJGiIv+kcm94NWO/MLpRgw6/2M9X38xOHKuGhGu5L4x+S1NYDu8hCifnXhIRK+ncXptsrwwRhk/45xfg41MptnTfDwdmoPjlOzGju068zhVmbphtqV4n3vmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=He2LA4gE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="He2LA4gE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F0371F000E9; Wed, 1 Jul 2026 22:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782943468; bh=EjUD3/8sAGl4tTnNrduRZnznV2dVOum9GVOCL8koIHY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=He2LA4gE2DtEg3r6g0Bo3VVhjmzVnbjAzWqWcatQl7F9OAU3zDgZv/mXbA5SRCyxk f8VPt06mb4K/zCh3uBPkiKJnz2Sd6Sg42ROJtzKkpVfChpGifmVnswOtumqthl/4N0 MWSTDjQ+EqIMLvOi9FAP3/ZAjtqoaQPs33uET6bDhen7L5nB9t4nO9c6Yg90DDka9h 45tM7AfrwXRBZEp7JfzLlM+Lghuf1ZpOLeDWUubV7WWwiYmEKPJB5O771GzHTjphcG TZ0ucaBWhOGqHU8c24kEBM93ULw+O2DkyWwanIM8BWkFSLGIxx0UH6R/TS3CgmVhKd AiEd46x/jYSNA== Date: Wed, 1 Jul 2026 23:04:18 +0100 From: Lee Jones To: Pengpeng Hou Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] mfd: tps65911-comparator: fix sysfs file creation rollback Message-ID: <20260701220418.GF2108533@google.com> References: <20260615065051.73111-1-pengpeng@iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260615065051.73111-1-pengpeng@iscas.ac.cn> On Mon, 15 Jun 2026, Pengpeng Hou wrote: > tps65911_comparator_probe() creates comp1_threshold and then > comp2_threshold sysfs files. > > If creating comp1_threshold fails, the probe still tries to create > comp2_threshold and can return success if the second creation succeeds. > If creating comp2_threshold fails, the already-created comp1_threshold > file is left behind even though probe returns an error. > > Return immediately on comp1_threshold creation failure and remove > comp1_threshold when comp2_threshold creation fails. This code is 15 years old. It'll be challenging to figure out the author's original intentions. Perhaps these calls are optional? Did you include the original author in the discussion? > Signed-off-by: Pengpeng Hou > --- > drivers/mfd/tps65911-comparator.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/mfd/tps65911-comparator.c b/drivers/mfd/tps65911-comparator.c > index 7098712ea008..2e5211374aaf 100644 > --- a/drivers/mfd/tps65911-comparator.c > +++ b/drivers/mfd/tps65911-comparator.c > @@ -130,12 +130,16 @@ static int tps65911_comparator_probe(struct platform_device *pdev) > > /* Create sysfs entry */ > ret = device_create_file(&pdev->dev, &dev_attr_comp1_threshold); > - if (ret < 0) > + if (ret < 0) { > dev_err(&pdev->dev, "failed to add COMP1 sysfs file\n"); > + return ret; > + } > > ret = device_create_file(&pdev->dev, &dev_attr_comp2_threshold); > - if (ret < 0) > + if (ret < 0) { > dev_err(&pdev->dev, "failed to add COMP2 sysfs file\n"); > + device_remove_file(&pdev->dev, &dev_attr_comp1_threshold); > + } > > return ret; > } > -- > 2.50.1 (Apple Git-155) > -- Lee Jones