From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 577B130276A for ; Tue, 2 Jun 2026 16:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780417060; cv=none; b=p8ZAdcy/7BS8qOhHsuT85qN3e/NJ6aULGXfQTUL8cW+jijt1SXq2rMIRECze0YIA8B48tB9L0vnsoUahVjl+liblFEnEWe4m8CA92HQjI5S/bOzzfvQdiPVxrBZhWlmftla6ZXELIxZL6IKS960oTtfWPCUJsz844NeQKlWKEOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780417060; c=relaxed/simple; bh=x595g1v47XFoBtUTqSo/5QbktGoik5Eti53VWdaxwPA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W/zQpmxGwiujCZUnHA8M+v7kgjtVP1KkpIOY72NKCWV3Vg5wkZjoQQXSo2mH2q6mHkDoR3oQ6RO4dnW8U7sE8Z2N9abiRF+DpIXMyLx5ylmfm4p3W6P4Du2uq5QXTfMK4lVQj1glxc1vLPDQkvVCSygAoQQLU8pPLusXk/Pv2Cc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GRIHU5Ey; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GRIHU5Ey" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7e6cfdc8382so969309a34.2 for ; Tue, 02 Jun 2026 09:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780417058; x=1781021858; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ytKizJtXUvrjcWF8Ia5eDr78EHJmWutwJX7hYAGeIWE=; b=GRIHU5Ey//IwcYtlQWZodf//RxqPRa3OKf6iAa4dDKCKLttJ1o8qpw4Db9RT0FKvj5 g1HGDhEAAzRL3M3yBcM23tnykPZbZ6g1H4HV2/bUmb8L9+SLq8Trqa6BLBQCYAlexEc1 41DXlTLmbZZkCMxUDojqFt2TO3g92EKUhYfOMd6HZEu55mGXrvTP9utLHXSdS2TpAfrm EGl/d8b8vCPOzjJqOLQLIlMGTbOoJAbeWALmlFVwKMztB8oedrio5vwAqpT0UYOJfZL5 KzWMQW+juKEo+9w/3rAQFjj0CJc+NUHkM36QUv0bh7BH5bnMaJ/4aezlhEugLuq4JPxO lkAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780417058; x=1781021858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ytKizJtXUvrjcWF8Ia5eDr78EHJmWutwJX7hYAGeIWE=; b=rEsS4wJDXymimr83CF+5t9s80fo/5gRQYEqke9F+4jXlTBnTwpElh2+FMZeDNm7Zf0 ls2lqmeTAFsDxyMegvcPzOl4AiYz0LVc6nj4dcK8GjzdHLLnEBim3Cu675AQ+8Ik81nh zrNIsRnoeyccW/72KCQzPQ44pFJvAETbNs11MbkojtqY2fVvcDmlzsPNghwOyIA/Jenj GGCMRhC6B1rAjhtwrvanuNnwV0flmEVz+YtkRBvBJiKRn6mUvZLXGKg9OoWFOU7QFyFv Mair53EChiK3F64qQqrVFd6p7cAqOoqoYxDLTaGyIhUhNvKeH/riLy7KiiuAx/zMq8bo 3I3w== X-Gm-Message-State: AOJu0YytwkyT03Y1m/eKGqb/wGIw+9WEx7m0aLGqI6pvxHyByKNSnQnu YBGzlBo9fj6FOf2HprCvsIfhWa7iLNNy9op3tuMCawR5B+rBV3+m3SRbOBbm/LxkanM= X-Gm-Gg: Acq92OFpLQkIQm8N6iyWh3Dz5SRxYfv45nIU/I1f5Xq2cXT/QzNYUcKCqELbuzP5TTg Mr0bTTeIdiaIXiFuWE0shfc3REY3wVucuRIxiWZa3l7zHedkN45JvBlI3hq+NFgQOcnwck9WwTE PyMuSKn/RYjKU6qRgohmHXhPHKO7VJNiRcVsKPIkuh1qSuTXF7x42jf9cG+WChZh5HWtRnzmVLz pfiJuwltaeA5VqxuxXdwj+aDTgdbl77/cQZkugIgM/pIEvb7vxGHTHHSbABaGTFuSuA+x9+WuCw 7Fqn6HxshiLNObcdyi6FPzJRviNrWyBG9+pkPl6gCpqpzLMGjS4u3kALSqcs3jk7splwnV+PW/v vqY+SwaXJt/yOhEdcn9wQr3/EaXhI4W81VESKoA2FReQ5/ygznuFH7AwVDtCu36n/IQmJGmzguB hIFCsFrYSB0I5jC0+XpkxAQkFwZ3sYA+buNc1/kARtUvt63YOOdRBACuRX1hr2EVM= X-Received: by 2002:a05:6830:6010:b0:7de:44a5:51d1 with SMTP id 46e09a7af769-7e6e61f273emr28018a34.7.1780417058098; Tue, 02 Jun 2026 09:17:38 -0700 (PDT) Received: from linuxescape (23-88-128-2.fttp.usinternet.com. [23.88.128.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e695d6b1d4sm10511339a34.21.2026.06.02.09.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 09:17:37 -0700 (PDT) Date: Tue, 2 Jun 2026 11:17:34 -0500 From: Maxwell Doose To: Peter Rosin Cc: open list Subject: Re: [PATCH] mux: core: Replace manual put_device() with __free(put_device) Message-ID: <20260602111734.5fad3a8e@linuxescape> In-Reply-To: References: <20260602043610.333426-1-m32285159@gmail.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 2 Jun 2026 11:03:45 +0200 Peter Rosin wrote: > Hi! > > On 2026-06-02 06:36, Maxwell Doose wrote: > > The current code for returning on failure in mux_get() uses manual > > put_device() calls. Refactor and replace them with a new variable for > > the pointer to the underlying device and __free(put_device). > > > > Signed-off-by: Maxwell Doose > > --- > > drivers/mux/core.c | 4 +--- > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > diff --git a/drivers/mux/core.c b/drivers/mux/core.c > > index 23538de2c91b..a31e06388588 100644 > > --- a/drivers/mux/core.c > > +++ b/drivers/mux/core.c > > @@ -586,13 +586,13 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name, > > if (!mux_chip) > > return ERR_PTR(-EPROBE_DEFER); > > > > + struct device *mux_dev __free(put_device) = &mux_chip->dev; > > This will also run put_device() on success, which IIUC is broken. Shoot, I must've missed the no_free_ptr() at the end. Nice catch. > I'm not sure it makes sense to use __free() when the exit behavior > is conditional like this? I guess once we do no_free_ptr() then it should be fine, since that should prevent the put_device() from firing on the happy path. -- best regards, max ps: I hope I'm not wasting your time, I was just looking at random subsystems and I thought mux would be rather interesting given how small it is (I do stuff in iio, and the contrast is crazy to me!) Regarding why I sent this patch, it's mostly because this subsystem interested me but I quite literally couldn't find anything to fix (except one single const-correctness issue that checkpatch pointed out)!