Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp302142lqk; Sat, 9 Mar 2024 10:37:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXzVJKXVWMzcUzD8IEyWOiE9RHZ+4hGmjMre7/GWXFExyvaV8UcRui96xWHzUtFMvP6PspBcnJ4T4+eF8non5XxEKAUCp0imx+sSMTUKQ== X-Google-Smtp-Source: AGHT+IFBpw6yOnsp5ZLTEZ5EXYrWMewlaphRKoULi2V7P1QDBcZDS5NFU8QY2ilZJGQ5vEiRm3qQ X-Received: by 2002:a05:6a00:1894:b0:6e1:338d:e01c with SMTP id x20-20020a056a00189400b006e1338de01cmr3531972pfh.1.1710009440180; Sat, 09 Mar 2024 10:37:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1710009440; cv=pass; d=google.com; s=arc-20160816; b=RTgDzmEN24o7FCjrTFWcjBdIHVsc7PhzqKliNgTCzHcvba2XE4nCT7Kt58tDB2IKoV K0oF9U5Q5D7NDm35I9/GCUrZokXbK7Z6aOOEl4Ti5QEOTByUxST/uB0iR5QDfQto4s7V zM1c3QGfyPbpVRQhU8azZ2oP3WAzgbSoliFJBr2D3xGrWI3VxbpffJZihittKYGuAyD5 rVicUBiFQKjWTzq47RUvO5hpVN50zIBp5GNAm5rLfwOqGcRmXVQ0tSNEC/WKXd2PIzmF K9pFyvjTXUwS+L62Fyim7Ym7S8Mx7epGEtD5FhaF3fOuwykfgl5Of1IUyjwxP0fRZ6qu ZR+g== 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=OANbyV2G/Z5hn8Cz4ha+L2z/SjARDZKcD48VqiqarKo=; fh=I3PgrHaF7bdx4Z/E2GLN2smE8lrKP/b7/pPSjTpmz+k=; b=ZKqiSgnf63m/3p+KRM0/4offEgsxsdpkbdZRY1HO96OuErNRs0XpyDgO3iSVTXwbAr xQmY6taSxL4bCEtXCPPaGGcPfg9xVQerbKLsNRtld20awosSIle48Kq52IsHcIHD6utg 8ZV1kApJ9Yd5OqDkY4Xi6/Xdvsk4UKszuy07BSIQTQHeGI0ddjFwDWsGscbegD55NyRO f22tXtw+W8vCfcBf5ZdVwBjf3mGFnAHwXay+0gT6quGUvYDzmCUusfIBNUnzfx5U14iT q06WwPi2c2UaDNi8rKVn8st1vmXv/X+J2ZYZ2BUgP0xKS7KPt0e/L2zn+6weB5o/Q9Tq mcUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ucyHH28V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-98012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b24-20020a63cf58000000b005dc8b9a9fccsi1844850pgj.280.2024.03.09.10.37.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 10:37:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98012-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=@kernel.org header.s=k20201202 header.b=ucyHH28V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-98012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98012-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A84A281051 for ; Sat, 9 Mar 2024 18:37:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5687445BE2; Sat, 9 Mar 2024 18:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ucyHH28V" 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 7A20945037; Sat, 9 Mar 2024 18:37:12 +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=1710009432; cv=none; b=BB6FWkFpVvLrmUnCILFvLQ0MVpPPBHW91BJ0tbCk5BxK8MR3S7NA/1yn6vqEGrhtFtAtgQAc9/r81zaLeMhmQ0p4ausdQpmkOsg5r4+n3stGa973zdr+m1Wm0/a11FHyGwBN1Yg/2nhJQZN1sob5jsiQAmXfu8jXQMospRuxlTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710009432; c=relaxed/simple; bh=QW7Gm46e+mmwfVPg98I+PIYT9eH/t++qHQlKXDiQ9pw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O5bl0djV1O6z/+6QIMjLIcNwFygQh7KNYLd/glojd2YGetFPlnjwH/6ijxPmNM59LpaBh/0eLP8YSQy/db5apsrhvekeItym4WP4vN3jv1h51hpj1hiinasD5HY8PyO7MftGciOCIXnxnCTR6ZOrCyBhRBh8QkRNugzuRpqO330= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ucyHH28V; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4F6C433C7; Sat, 9 Mar 2024 18:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710009432; bh=QW7Gm46e+mmwfVPg98I+PIYT9eH/t++qHQlKXDiQ9pw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ucyHH28VOYLm1i/YEe/fQPBAb5m8/NoSYPrgjtI8r7GfX4M0NFgpBnX6eKe1l6INn EhrRwpqDDkXm1E+siDN44uHAJrimeUlGzl8et6l97fkeUbnu2EqDuzqZj6jgdESyTY 55jZ0jJQkgx7bnhWJCdoaDwjjR1s7yiB2Vd1yUpckHrLykHz0crwDdD2cf6mhnj/AU LZesoxIQos5PGygbsEb6Qoo5pPkd7rMNQ27Mq3ZA3obO4oa4GcPcUqmUUGrtKQUzIS 28dVhnoHOEAl1FHfmi0qHZsjGum3eD9S1hLvBm8DJLyMo4oBaI2ndut6Q8jkg50BKy aCETBmz7QXwzg== Date: Sat, 9 Mar 2024 18:37:00 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen Subject: Re: [PATCH v1 1/2] iio: core: Leave private pointer NULL when no private data supplied Message-ID: <20240309183700.60133d78@jic23-huawei> In-Reply-To: <20240304140650.977784-2-andriy.shevchenko@linux.intel.com> References: <20240304140650.977784-1-andriy.shevchenko@linux.intel.com> <20240304140650.977784-2-andriy.shevchenko@linux.intel.com> 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 Mon, 4 Mar 2024 16:04:32 +0200 Andy Shevchenko wrote: > In iio_device_alloc() when size of the private data is 0, > the private pointer is calculated to point behind the valid data. > Leave it NULL when no private data supplied. > > Fixes: 6d4ebd565d15 ("iio: core: wrap IIO device into an iio_dev_opaque object") > Signed-off-by: Andy Shevchenko Fix is a strong word given any driver trying to access the pointer in this case will be broken anyway. I don't mind it being backported as it'll make bugs easier to identify but I'm not rushing it in. Otherwise seems like a sensible bit of tidying up. Jonathan > --- > drivers/iio/industrialio-core.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index 4302093b92c7..8684ba246969 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -1654,8 +1654,10 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) > return NULL; > > indio_dev = &iio_dev_opaque->indio_dev; > - indio_dev->priv = (char *)iio_dev_opaque + > - ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN); > + > + if (sizeof_priv) > + indio_dev->priv = (char *)iio_dev_opaque + > + ALIGN(sizeof(*iio_dev_opaque), IIO_DMA_MINALIGN); > > indio_dev->dev.parent = parent; > indio_dev->dev.type = &iio_device_type;