Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1912750lqg; Mon, 4 Mar 2024 07:29:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjt7vvC/JspHaLta0lAqzvnvTATrWNXh0k/PJRds84RTz7L0tuU6rXkMkPDrFl0hBrgMGHDLAJrz2HqUgolgEUjmwpSWZdQmTw2anHTw== X-Google-Smtp-Source: AGHT+IFxAkoBpSq++GUDjfrQx/QG7TTjVlLgt47v1iypA9GujKXCbotkxKHMllSFgHN8msf0PR4N X-Received: by 2002:a05:6a20:f397:b0:1a1:4d56:7d68 with SMTP id qr23-20020a056a20f39700b001a14d567d68mr4590923pzb.36.1709566185658; Mon, 04 Mar 2024 07:29:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566185; cv=pass; d=google.com; s=arc-20160816; b=wkLqujpqAGgNzW+JTG9aoQfTtC8EaA4Qg2Go4VMjKFi9EWEbUOT9bLkgmWX4rNqI88 SAD7yPiHVIUaBbJK1xdG/C68efpVRISyfORFrTUtVW06z8qS4Q8F5POmaQv0fuYcP/Xz PNTnytrzi0O3Er9lAPCpWcuvpqQ1MX37kjYlI9Cr3fyOPwomls9TuPn90DdMEy2dxD0P CUbZJ26g3wiPhd00Sljus6SnYdyx3mKlhhbc9RS3pVQu0tryQZYw+8hlc7PYuPZHRdo4 xsDz2LUgYyfaxDDAv//rO9ogqjxv22QeacsN/VaQ/HVFyr0Is9v/AsPlvj8nL5psSNHs T/qQ== 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 :date:subject:cc:to:from:dkim-signature; bh=wNrtOs1CvKEB4D3kifCdPVPHTPMQ2wGWKNob63ZFsic=; fh=3KYPR7QXAO3Qw8iC6kE6TwvD5qXD4BfVx85ivp4WOmw=; b=cTlT/5p+iyBJgLIG7iuiGTfMGNkugpnJC+pRll4Damfn+m1ldbq2WR+s1/yDfCFjki 7teack8g+SVma0YIMh2jZSk0VLgKMZWeBw6T/qBmtDO9HbEGAjkFfdK8nc/xZRr/RLmM W4wKMS22dZ5NDl8YR7Ql/LAyGOEKufKHBf8rM5xVajEAahfpDlK6KySdXJjciFxoLahD sPvbYDTwONFb/hoDPmBpO7enAnfoaYD+m+xKub74qP3pVXXl5PjSDr2/LJ4x2tiLgYuD A3wSNkcw7z8YaMalk008mZgZfCEB8LdlUcrDs8I86JLlnMJK+JO4gh/MekeoJhBBWva2 dYcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Lg1G6v0T; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-90706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p22-20020aa78616000000b006e46536aa3esi8138034pfn.39.2024.03.04.07.29.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:29:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Lg1G6v0T; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-90706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CBC79B219D3 for ; Mon, 4 Mar 2024 14:07:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BD1A45BF9; Mon, 4 Mar 2024 14:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Lg1G6v0T" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 19BA23FB1D; Mon, 4 Mar 2024 14:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709561219; cv=none; b=UvGMPfHuiPh2nogQzJnrKChHpg+kTTFOuYQFWXwpto85eq/XkJceK8w7NQOMWMz5Y6TCfkl3E5TkDRhrEuWWwXaab6u6g7FIvVFWxcydMXfcA0WNc2x0c0sEx00woMY/LIGopY8Z/HG2q1nQgXY3MVmzC3+jdb8fsKVo0LBxdyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709561219; c=relaxed/simple; bh=URTHF9Nl3Pd3iMTnwOfXWfyaLmcvXdfv/9NJcJXxRAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DzvoHGkaz1sk6kx//PBFWydwnRkMir+N80xqDJZS8+hSCVhsd+ueCSoS8OJmXH1wQ8OMQ7O+SrXKQ3XfQZJprCE4+Cxm/y1nLGN5ruHYoQ2Z5dU8erb9jI4DoJ1EfywdnnQvu/nKEWuci3LzHiZL/uKhqpsu+tOStrvbuwF6u2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Lg1G6v0T; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709561217; x=1741097217; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=URTHF9Nl3Pd3iMTnwOfXWfyaLmcvXdfv/9NJcJXxRAY=; b=Lg1G6v0Tz+y/h0v2tL3Pn4ONzeuaQVyOzvy72j1HXedqboaNjHfql6gi jScng8tOOvYKEFO1MAqa0RF/W4o7oBaS8lsJNyu1CmIqs41G3ycqH3pZq y3vrq670ZQeAer5Za0P+1rEz62scZpoPLlRfaMdH34ASGy+l9+oUvT6KB NFX2XR3XmkkArDXvHPQqcTIVeLU9TsOn03Jf9F8cMOL53fv+6hl4SF8e8 sZRrWqmhW4AFonEsZbl/q5JeS2pn7/nukJr2n/NwMDh61Mss0+k3vyP8e 5msG/35GxII+02e0BIXp0EMExT7C5icsqYgG7kc0sD1YJsUFcf3ZY6tjb w==; X-IronPort-AV: E=McAfee;i="6600,9927,11002"; a="4214187" X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="4214187" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2024 06:06:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11002"; a="937040571" X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="937040571" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 04 Mar 2024 06:06:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3CED215C; Mon, 4 Mar 2024 16:06:52 +0200 (EET) From: Andy Shevchenko To: Jonathan Cameron , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 1/2] iio: core: Leave private pointer NULL when no private data supplied Date: Mon, 4 Mar 2024 16:04:32 +0200 Message-ID: <20240304140650.977784-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240304140650.977784-1-andriy.shevchenko@linux.intel.com> References: <20240304140650.977784-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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; -- 2.43.0.rc1.1.gbec44491f096