Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2107387rdb; Sun, 11 Feb 2024 11:37:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmfbu6DzKXIY0BYekEhFTC5wDw4asKgwrDeAah+2XROahhSc1fvYD8GgSfGQ4Lm1NMimlL X-Received: by 2002:a05:622a:50b:b0:42a:4a36:d195 with SMTP id l11-20020a05622a050b00b0042a4a36d195mr6399337qtx.20.1707680252386; Sun, 11 Feb 2024 11:37:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707680252; cv=pass; d=google.com; s=arc-20160816; b=QOqBHTYIFyXrF/6yXgjTUaBXbK50xTjoZxXS4peBkNYzbW3FClgTXMJVbz/8EZYv13 hUsJ/xHC3K6ngtXQAOja4a9711tD4n4st2a2I9gzrcpKrje/b08W3CI3Z2z+saqenlJm q+TAb2B0flLwTbF0B1FWhKCYjRzO+5Sdo5o1f8mdlXV4h7cCFxJCIm9VLIxeFQ9jptqj T+PCkvwbpmvh5FbcUlpI5ysx0sS3uFYmWjTTM32/jwWQ3vCG+6IfMuDQq0zYAaB7qMFP 2HypxR7n8D4UYTJ4W6fnY6mprD8mMHFMdDgFz0uY3DCRmQpep3L93dzsQFFV6L8aSTyS iI9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=YvkYqm713OHVQJmyDyE8IPxFD3a7mib9Xhc1/GBHT60=; fh=uU/XF5OqBdmnRTBPxyLR7pzu+P8YkB9pxqmAFwCdyYM=; b=TpLAt+3CtX33TwrIgwcoLMeXj1wFwam8OcFfIGtB5w91Uvuo8rcxnhK5OCwyKpcGKr 8x0belj7F2FEELCm7mXeGjkBcczhjwaDb+r/8wiqra2jM398M43lx+4L/uKRAt7e1PWs kq/ts9trWi6VYI+4a1ejqU95arzQKI6/hukjWFI80B77nBe0rD7I28amh7yMlq0EjKV8 Rx/RFu27/eqVY5rC62ZEudApkxbSkaEgETlgrl1/R60o8Y0PJsPV0zTwrzyrwDdWcL+T rLWwx0+YkvABdeMlGKe8XLzQUp+Bh3ZHvxPMY+oWB2VJsyJLTSu7n/5HlTfQ0ZCRcCge Bx1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tYQRuL0m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUX2cInPCUkGgFA1lUcGCxzZWz2uf1P7qIvOIzggYVbiRPZI73VL2E+GJt0ZpAAO9XQ9d44m7d/TnKFCz7uZIpNzIq6M89Dv6YcBGFvsQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a10-20020a05620a102a00b007840a19266esi4339435qkk.572.2024.02.11.11.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 11:37:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tYQRuL0m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 25FAD1C2110D for ; Sun, 11 Feb 2024 19:37:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD9F55DF1E; Sun, 11 Feb 2024 19:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tYQRuL0m" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E362D5C90A; Sun, 11 Feb 2024 19:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707680244; cv=none; b=DtcsJMxt9TL9q13A3cz9CPAXPsYV/wiDzAoI4K8bsQF/G640Px+06ChEefNkzw+AH5t12EIIHzJ0uqzfbXfBccA7tgavZjr+askn1RKTj5XvrKeHm7HSIASqgspwXaSfym3SnFH3hTkYvF4l9zd1wDB9OBrmmoi8PG5+2X1B/a4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707680244; c=relaxed/simple; bh=5oFPK3XMyl8w2jJth5vxf9+kHoqJQsWI3K4xfwNY57A=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LC9XxFoatJgZ40daJhnzzPA21bFxAtVU8fMMqaD+ClQLRgeFrN5z32bl8tiOAckC/WJCi9lsdXHxRYpQ9Ix1A98htw2gK+guMUPRZKMQ3zRqE7A0ZCvX80vUSQhbrXPqbG7cgopdsTn6tr29JwfEV6utZN4I1hzRb6izavF7Qzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tYQRuL0m; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDE07C433F1; Sun, 11 Feb 2024 19:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707680243; bh=5oFPK3XMyl8w2jJth5vxf9+kHoqJQsWI3K4xfwNY57A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tYQRuL0m7cpAzYcUgAoYObc55ZHJtJW73n95KM3172I4fWSmEX72iAucjmH8XSgm+ uSb3lVkRiE1nNJQfKOBB31rJ711GaeL+1sdwVnJWGo4uhhzKiXg5LTWIjsBI0qYBIm TAI5hyCo4Ph0mvJXydNEZuB0TziMQB7kSHpWbGq6YwxdTX32ITStpE/LNjrDBE4YmS auOfMvBbRHWMX5NiFGsEwtyI5wPkSJX0dayMvxx6ukoR5xP0x+FtfqJYbdP4xGARhX +aCvXXN/SfBi/Epu2lCfqhrT0/FD77tF34KNKXdMQvsoJi9yiXbT0K8wL6FA8CJwAE GhlmF9oAzEAgQ== Date: Sun, 11 Feb 2024 19:37:11 +0000 From: Jonathan Cameron To: andy.shevchenko@gmail.com Cc: Dinghao Liu , Lars-Peter Clausen , Alexandru Ardelean , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: core: fix memleak in iio_device_register_sysfs Message-ID: <20240211193711.518b76d7@jic23-huawei> In-Reply-To: References: <20231208073119.29283-1-dinghao.liu@zju.edu.cn> <20231210133228.5fd425ea@jic23-huawei> <20231217132800.27e83a01@jic23-huawei> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; 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 Sun, 11 Feb 2024 21:16:32 +0200 andy.shevchenko@gmail.com wrote: > Sun, Dec 17, 2023 at 01:28:00PM +0000, Jonathan Cameron kirjoitti: > > On Sun, 10 Dec 2023 13:32:28 +0000 > > Jonathan Cameron wrote: > > > > > On Fri, 8 Dec 2023 15:31:19 +0800 > > > Dinghao Liu wrote: > > > > > > > When iio_device_register_sysfs_group() fails, we should > > > > free iio_dev_opaque->chan_attr_group.attrs to prevent > > > > potential memleak. > > > > > > > > Fixes: 32f171724e5c ("iio: core: rework iio device group creation") > > > > Signed-off-by: Dinghao Liu > > > Hi. > > > > > > Looks good to me, but I'd like to leave this one on the list a little > > > longer to see if anyone else has comments. > > > > > Guess no comments! > > This patch does not fix anything. > > Yet, it might be considered as one that increases robustness, but with this applied the > goto > https://elixir.bootlin.com/linux/v6.8-rc3/source/drivers/iio/industrialio-core.c#L2007 > can be amended, right? > I'm lost. That goto results in a call to iio_buffers_free_sysfs_and_mask(indio_dev); which continues to undo stuff from before that call. Now if it did iio_device_unregister_sysfs(indio_dev); (as per the label above it in the cleanup) then I'd agree. Perhaps I'm misreading the code flow here? All this code is supposed to be side effect free on error so I'm keen on the change even if there is another path where it gets cleaned up that I'm missing. Jonathan