Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2121408rdb; Sun, 11 Feb 2024 12:20:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWT1fDcR6T8XyIuLx+9J0DzDj74RglUr2WUKlzImi5yZ1GSDuDPOrGdlOOlf80rmougbo5Y6A9MpaeC2zG+Kg+5AnQr7X1WoTxs0VwfxQ== X-Google-Smtp-Source: AGHT+IFM8o771OifxJi+qTc94KY6YXpy3jfA4SGxKWEn/KBXklgQTiM0x77JoSVYxOZI5H9RdGBF X-Received: by 2002:a05:6a00:4581:b0:6e0:a312:1f3 with SMTP id it1-20020a056a00458100b006e0a31201f3mr3953150pfb.27.1707682834345; Sun, 11 Feb 2024 12:20:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707682834; cv=pass; d=google.com; s=arc-20160816; b=F6cmCo8Jns42zErtzd2cecRXGzRu905mjuypxKB9hE6U5dWkUBZecq8HA381kPsVM+ KmfijYrdEahkHRn4YAFhDaf082IQTh9JG3T0S85vvouTzA5znqp7o2xYMa+sy6mbfrxF yRqEpMb+EcqyPqzgQSvzt0TVRZEjLju3G3KeYGLez/S8ouqnCXb7lgELMu96l5RaYQiV 3kODZtS3NMeIjkcRNLa/nfD0jh09YxRC3+XQKuAGPLL8nfI3CDsSDMDNvJ+VrtXab62a MYE2PPJZ/9mrLwkkOMj9WOLKRVO7TyLtdNSLx8LZfDRjvUpX7lRNUudZS8CgaZ4Jx+Cm NlzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Ghy+50tCdn+Q71lUqzEnDQMJYH/opBg7prwVaaY4Heo=; fh=HkOaBQy25nvci4EANp2+NttPfqnsC4ocyzGvx5yR1dc=; b=PTvWJD4AGfq9D+RgOqNaHRZALatHbNI0G5WK/APzOK2Xe38OlU8c3Kqj3U75qwiCoD +YJjEDlIjomcB4EP4tM49iqbqWvkiA5lCDhj6tL0rFEhBdS9z8j8LQWrvMscnPnz4LgB IlmPf0f2sju6Iks69PSfnxgS3LDSmLQk+aiIAox6TsXHt/LhWxd4BfoqLUo3nKSnkVDY ofaMVvtv2XPKBqudZX5kLZ8/8b+DgYQMAlpQKSdUERgSY/mANYoiUD3FXXP/T+Eyd1zs agc7IGYs+u9s9yfQiPGe+VvL4eYIHp6tBDTC8l6wayrfsAsbhWluSjwWwxjQVsbSe2du VIvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Q/xQ3d+8"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60945-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWI1vsoRlRHheysMocLkPiE1gOyYu6mmymrplRolPas+yAj4jGsWYvrTp50JbjSI269nk59VkiMnJAclff4lV7pUBPi41i6Bp8gBdY/Lg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a15-20020a056a000c8f00b006e0aca4d546si2427784pfv.393.2024.02.11.12.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 12:20:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60945-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Q/xQ3d+8"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60945-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 07940282C71 for ; Sun, 11 Feb 2024 20:20:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDB425EE6D; Sun, 11 Feb 2024 20:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q/xQ3d+8" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 3BB10149E12; Sun, 11 Feb 2024 20:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707682827; cv=none; b=KcUxgxN79UEbbJxllfhgE56irIkcgSdmkYIUhL4a5KOwxiIYmbbW2e4agYG/BHbIoiKgntuu7QquA6oZrQu8fQiloFOHj5WhG9qyQRZ9bktf2v6nS7urfRJcC7ZJX56uKHmxne21yr/qeR95Zgj6SYizBCF4HYpOMo0drS8rAxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707682827; c=relaxed/simple; bh=bzOg8Vyf1KgrI24EqX1HmE/A9hdeNubSy72njvMixRI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lpjS417fJtLmRs3VjCcIFjlXHdKIYKa5cThh407eD0G2payQmkvW9ArzFZkX06IDvlEgsEEAP1bOjkeoqRgrVWqwj1sXSlFsPfXOi8AS4dzlbPDNr0Mn6jQcD+ublITZa93DJFWCxGO3xhL30HUjDwNt+I0N5UiWEnTdn1hNKro= 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=Q/xQ3d+8; arc=none smtp.client-ip=209.85.167.44 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 Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-50eac018059so3284508e87.0; Sun, 11 Feb 2024 12:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707682823; x=1708287623; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ghy+50tCdn+Q71lUqzEnDQMJYH/opBg7prwVaaY4Heo=; b=Q/xQ3d+8p2DNCCXLpz++2GSMQz68rdNAmlDEEpa6sbd7/GthxFQ/FThp7SGG0PeWgI w8qCPmB70yRLtagLufI0ZmKPrkMkDbh+E8ws5Lr7nHHdSAIO0F42zLiWkJn0ZhMoT2LY eF0+RZ2Agj6J0bGQAxQRTXPnAXi0lFV3H0iVM9EiQu/lenFdL8YEQYHGnf420LBEFuYM BgKRKzoauZWgtfoTM60NNApCdYxJC3m5HWlJ3abr22OneLYRtZqJDvGdoGo3aqJq0/0i QU+84ZJzjHIXycnoBA0kL/ODgLO2vIIpAfDQ37SfAv1xR+Yc4wQ31Gy97rutwZfmnhhV eArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707682823; x=1708287623; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ghy+50tCdn+Q71lUqzEnDQMJYH/opBg7prwVaaY4Heo=; b=Wjo9sXA7WjBWkHwTAeNMzy/9atTCSe/mAmPyPYgCp0iQxHGO8GobF0GOA/T93Deb4f FomP+PeFSauxAIYuvAZ3J/nVtSNT63iah60vo0AEOMDTPXWmH0BUyCEn5BCBCbmHyM6g jMMZR4Ja/rD9OJpWGNEJe0WNhsWVynrAaTtX64oa+dRSNs537MFw+p5d9AB+9EEVTIG0 fgMnUBR9YAtb1Y6CMfXBWGS/Vm+edLQy88b+A7eBGudyWma+dvQNXG9fsjcq1bybTOth agho/y3z2LJQDqv5YfPrPtVQrR5XIROjkOSLUFGJBMr0d/tabMSmRBrqMldum+aq2vOu 3YBQ== X-Forwarded-Encrypted: i=1; AJvYcCVeZ2ADL8WBphwbdYwqJcYPZ/llo0FPGGebu067RYoh76JGd/+kx5dX/8fNB/ptcNrPZn8vj6rrJX6v7iHQhUlY9tRrEqkmgdpyUqh7dY3venEK92Hir2M2AZxYBImvppAM3c7mlM20 X-Gm-Message-State: AOJu0Yxco8BQyyAk4GwRtFa6z9X0eX/d6o00ivWU0DbQLSsHZ9qmUz3Y rQSOig6YqZsSbTOz+g+O/BUyJHN8Go8RZ+g9smvadKWmymlCY73IXBmmo3sRYk0kdwPRD3WweoV bQJyM4XxvJ8XasR1j2QTmL7OCu2leNtX1dGI= X-Received: by 2002:ac2:5bd2:0:b0:511:5b4e:1063 with SMTP id u18-20020ac25bd2000000b005115b4e1063mr3243010lfn.24.1707682822979; Sun, 11 Feb 2024 12:20:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231208073119.29283-1-dinghao.liu@zju.edu.cn> <20231210133228.5fd425ea@jic23-huawei> <20231217132800.27e83a01@jic23-huawei> <20240211193711.518b76d7@jic23-huawei> In-Reply-To: <20240211193711.518b76d7@jic23-huawei> From: Andy Shevchenko Date: Sun, 11 Feb 2024 22:19:46 +0200 Message-ID: Subject: Re: [PATCH] iio: core: fix memleak in iio_device_register_sysfs To: Jonathan Cameron Cc: Dinghao Liu , Lars-Peter Clausen , Alexandru Ardelean , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 11, 2024 at 9:37=E2=80=AFPM Jonathan Cameron = wrote: > 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 litt= le > > > > 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/industrial= io-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. Ah, it's me who hasn't noticed the word "buffer" in the goto label. Yes, you are right! > 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. Everything is fine, sorry for the noise. --=20 With Best Regards, Andy Shevchenko