From patchwork Sun Jun 2 17:23:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erick Archer X-Patchwork-Id: 13682981 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2087.outbound.protection.outlook.com [40.92.75.87]) (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 95C225A0E0; Sun, 2 Jun 2024 17:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.75.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717349056; cv=fail; b=JjtJlSS0bSX2DRAngyfDEE+1dN/qKbwj0IbIUHd5/nachhl9kigyHeuHjMcfjqUpdC65wJQ8653oTMmsq/UkL/s043QjmezVC5bYfk3PKV5TNscqrxrCpCL+mieMbcQgUbLF/AAfNSFA/Q+bN7E1onWxkHaSP1G8GQuplbU7l+U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717349056; c=relaxed/simple; bh=o1UyOYCbORytrrgw+p8KenbRmSZKV8PI+EnUyM217bI=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=HObMmEPxkc+sRDPJDB8a6yUDjtHA42PmBfI+itvuDy1EnilEbB/cxpn8TqsslgL4g43brfzcA3nVMh5c6/KbvPUb2MmsGrMU1RSi8dLvHshkfch/4LxQW0G1pKD6QgaSIbI4tGKNN86AVgpW1n2qcfBs6itKFCZEmA85YXo3Oug= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=HMRx2tXQ; arc=fail smtp.client-ip=40.92.75.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="HMRx2tXQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRFd6ycxgQ3DPxU5ZoE/Hc9dekubzHDEGx4tyssuFxX8W4iKnt6UiEX1OV+a7DLOsm0hoDyrYeiDBTw7M4qKERURRd/ASvN1z8xGkhMkegtTlZ/qcDhZxtFQdQURd1tpJzzLRxtwsZ+U7mFXbZvEGt2OR9QFx2VI16F8Hegb9O2KGUfNI/wkcdMqGlxqf98Dbd1UGhNPlYQ7JGhF14sXL8//FOgmwgW5/ZDwgTF+EsugAmyvkfjzqMVyqMaAPkLc6eFtSpfgmToDJ/TFuM0coBwXMBbT7roJ7mVBpptNoZD3TxK3PHSTSjQdf634aLVDVnzwXK0L8qBCwUMWzfHIOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WoOXGdJnDbcyQzy1mLNWBguXK972w4ufsNfdQLdD+rA=; b=kYayAneapvVqAbTwMTej3E7FA4R25fdkCArtq5kMLte2B/fooOmawEa0mKuVesDEqq0ZWEnFlBlUYFUinrHtPbgGWgzqn/YQOLUf7H6cWF33OtQ9oQnFwttom5EUDw4PKh+Go77gWd4sPuh7f2z3Hi1NucOVEwPmYOCklpRJFF1wRpsCpetMpgJmAMtz9tT6LXdKwyZBo2g6Yq2un50jQZXsTUStk2w3dsyTWARX6/UMc9ef5+TlKepo1rsyGuUtVqZ417jmiCoc+HQOkLq428gqkVKvphNaKb1kBsxSD2k1CGQxPNZr+40qI4AvinMvCl42eBOKnPWa8GBOmVw3Xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WoOXGdJnDbcyQzy1mLNWBguXK972w4ufsNfdQLdD+rA=; b=HMRx2tXQXdjPO/WBEWenM4Xa70B2LT16nG5Wg2fiHjVkArbf1N0YGM5hB/YI8oBot0nwTMipYq53aQk6z/+iXPLP7v3uGoHAqWcjQZcA6U71F55Ns1dClXv0O+ItWHWZM6+DGqyMbXeqjy3RH/3InuvEfxtN1UFJQRah93VsMxL5L2NN132dPwyZznKmw/FYFV8uGfAJVkb0N2ka0nubyiupx4/NVe15/ZpTGxQM+K/2sk0B0CFTm47rKoTa89/m/V5FFWo/HRXoD6uDR+qKPxbQDoCD8phaAFqjKrYjjuPNcmopdEc4Mdhpz1FhGmqe5xwlMfD8uX0tNzjKJlqOww== Received: from AS8PR02MB7237.eurprd02.prod.outlook.com (2603:10a6:20b:3f1::10) by AS8PR02MB6872.eurprd02.prod.outlook.com (2603:10a6:20b:255::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Sun, 2 Jun 2024 17:24:11 +0000 Received: from AS8PR02MB7237.eurprd02.prod.outlook.com ([fe80::409b:1407:979b:f658]) by AS8PR02MB7237.eurprd02.prod.outlook.com ([fe80::409b:1407:979b:f658%5]) with mapi id 15.20.7633.021; Sun, 2 Jun 2024 17:24:11 +0000 From: Erick Archer To: Jonathan Cameron , Lars-Peter Clausen , Kees Cook , "Gustavo A. R. Silva" , Justin Stitt Cc: Erick Archer , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] iio: event: use sizeof(*pointer) instead of sizeof(type) Date: Sun, 2 Jun 2024 19:23:54 +0200 Message-ID: X-Mailer: git-send-email 2.25.1 X-TMN: [2Gh4QwnW7K3cdB+Q6ceNdfyHrZSWlBVY] X-ClientProxiedBy: MA3P292CA0013.ESPP292.PROD.OUTLOOK.COM (2603:10a6:250:2c::6) To AS8PR02MB7237.eurprd02.prod.outlook.com (2603:10a6:20b:3f1::10) X-Microsoft-Original-Message-ID: <20240602172354.11432-1-erick.archer@outlook.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR02MB7237:EE_|AS8PR02MB6872:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b2c5dce-4729-4664-c0e0-08dc8328d145 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: QW3BewbwJ4MoffCr2GE6IwAs3JPUkE3mkb29ErF7bo7r07oIk8ObBQXB8Kl9b1JX/T6mK32lyCJ0CvkIHgUW14XE6hfnaJyTsRMPaz/NxH9k3RhiW22gCKNC6fl/V1im0OkFQMerGbipjSUFZ/cTDuBFOfHOva+InvCG39FM7Y9NGmsFMZXYUSd8PJTSNBiOslwQ6A675YmHwpKLJNGLQbibE9nUb+oid21oBRb42cVSlMFO0e+jE5x5L8W79jvshwv66GOudHGVG/NiLpP36EHGuvMV/0Y9sklXgwlbmoADEQaupZbOVcNR7w1kMd8BtK/7uU8V6sJbjhBSynToBo9vufX0Q9ZFtt5Knt1i60yFe55299+P4P0p5kWb3jkeVWfNUifuO5c/JzpLWF2PtCTXXsSadlpRxFcEiWd+PoGAWoN2guuopd3TUGA3tIi34U9kkN0+dQ5FYwbbONK9iRsy5DUUqQr0i2wyTpptRoKKB/qBsx7vLXnuosyUZOigfcm3SY+SARfAF/x+aAJcZ8k0MQBS8iLvLRwWnPgVM4/dKhKQOnkFaow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2MWGPmxJ9w0MdM+Ns2zf9Clj4K8pTWC+tVJAso37VtNzCTfw3+aRVz5CL3qZKIGgUGcZzSedbTV7t8nr19aGf8xKBcGtp+dga3wr/xori28WNXK1aIOH9B8I0PnlcrG4t/1E6qfWwRWzcbMVGm7eL5lXiltn1DyShVXuW8RThRrngJZjqVDD4rk1EUzfoP2A55J/Apvye//58jFQJTAUfH8ne9Q0MguunS4grjHoFvOS2iD6nK2aegIdYdcwGhmLImFlRnk1bq3/6pyJA8dYgs55vXf7uPNEcAKJZjy3x0dwHzVbUH52KmmB/KV8d80Dt X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b2c5dce-4729-4664-c0e0-08dc8328d145 X-MS-Exchange-CrossTenant-AuthSource: AS8PR02MB7237.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2024 17:24:11.4895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR02MB6872 It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). At the same time refactor the NULL comparison. This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/iio/industrialio-event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 910c1f14abd5..b99bfeff7d37 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -572,8 +572,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) iio_check_for_dynamic_events(indio_dev))) return 0; - ev_int = kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL); - if (ev_int == NULL) + ev_int = kzalloc(sizeof(*ev_int), GFP_KERNEL); + if (!ev_int) return -ENOMEM; iio_dev_opaque->event_interface = ev_int;