From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 6A51B5475B for ; Sat, 13 Dec 2025 14:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765636797; cv=none; b=hvYGGfUidrUqDW9lKsNrRRl4rjcw3c+vjAMH0q8/P8ejSuWhgAQL8J4wD+dBptRBs9c5KegwPjgvNiOjjAIwV3xmiTlZGO23LzQGiEUbyLN13Gkgmj6CiFn72KxA1BLGsFqLZdT94rdHM2Hi4FlVlp4vnk6kv1lVYi3dqA60HcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765636797; c=relaxed/simple; bh=TO0Vc04SBOWQX2FHQXYSAfgCIPgdhpi+DqfEsyORZJk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oJu+UileMGpSFdWVLRaH83/Ob+962vbG6yJePd62mMnEbktbo1U3KWY0L92KOU5xcnl37ekUepq3fXpC6s7+AvtNKTznmYO89QRYSbQMp79uSJgzXmUs3GJWUGrImJVz8mnF8H0wSpWpOWYQQTyusdygXuaL4wC8NbHvUJg49v0= 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=HSJRz63Y; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HSJRz63Y" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-42fb03c3cf2so1113498f8f.1 for ; Sat, 13 Dec 2025 06:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765636794; x=1766241594; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VvAGfKFGF3RuaayUTSdoZFybLUCkoSlhrVT1qkFOtyA=; b=HSJRz63Y6qVQgi+WY8oImxZeyUF8rHsfDhkj80r3OUkye6sPiVeGWeFewE5eSJPZ4L CUR5qiqhabXp6sXsZE6OrlI0qD8dMge1kbXdYFZ2l+wg6iRC33nbAXn8AHYWDKXz8u1O GSoQQm/0zhdgMcaxTPoTeN9CulGSfveHjRlJuj2PhXoAUofK6wQco4NJJ71jHEPzJtIF Rm8CvHg7mXjhqZE7+ibwAqoGnDFkxxexVWIkkwBFmsXfEvnq5n3N2Gb0/SUU2448Qn3f wGzw9ON9/aPpU0NGBiXj6u7OVB5sFe6LVWofVIlf4TPY1z1n57xwRULZZXmuFrQ8jlJ0 uheA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765636794; x=1766241594; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VvAGfKFGF3RuaayUTSdoZFybLUCkoSlhrVT1qkFOtyA=; b=DE7n3Mbt8HmZ1OLzTXJfOqu7wyBXKxgrS+ugUjGJQc6oKBWAf6RRS0RkknOHfErB4l l0Cu//RtcCOnICykAIumfA3EmDIZZEjy3yIfddGjJKctQUFUmTTsjoz/1kZAEijinbJn IoSIJ17Y/SdL9ofjGV0m/TP8D8u4aTd29RyIalbtvgA87OD5DxKghY53KNDBbwwnZJEi wZ9ovfxlFyVp6zSqS+K7CThu3rYTK1zYm1lMnPZ8i3HUK9fvk9XMdixy87OVyMFbw3pX 7W1iqcLD21eyHnWJT//IzktQfJMwuADjAJUkeFFQRqSypCY9aqQhdk7DG3KSnzH5LKDw YdlQ== X-Forwarded-Encrypted: i=1; AJvYcCXSm+uplZQfKpXDfCCW0iyc3YnILKEIzlLyzRXiCdfjuKomOVo+2qH5pKOiXsRaHOde9ijnSgCZ5I9WReo=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2k0TQ1lMvkOH2htsqYy1e+7v6uElh1TuW4/y8efNmTtBkYd0S p1JNJn2wyMM90U/jKN0M1dXBvI7ZrpUsMLPDjlH1NUStH2h9PHWYosbbqOKXTQ== X-Gm-Gg: AY/fxX5gIyzmXfp8i85a0YLuREnC5DJu8Ta6Gc2T3qDGNQgQKev/8FiFFv5l2iCf/rk O6nkH8M2BuTXAdgHUYDuc+zWA9dSyigL6SsLBpB1PEDZaN94koPuqhrni1n0Qzh+UEhOhV7oH4r 64fRVykyrkgOLd09HYpTyrPv3+5qSs1FqzgqWqU0J6TTFWJeFtbZpAFhq+xR1LqFJAlHIFTmN34 KQfVhIB3TZJ7y8ZI+ASI+k/Gp6Dvx85gsOK+FZtyNYeHE2AFHWFZk8jNsjo8SvCgdNimDZJAm/C YaJYE8A3oh+QGs5YXhUCRFhfm7KRXc07bLd7royBpImzhK90olTqRjeSKn215frNL6faA5/CPMA 74aL0cFGgzOkDyDz8CL7DM//ySDRZCHDluHGQ3Edj/9q69U7DHvuWmoKOS+qg0qdNzkfQ6N+wNN P/k6A= X-Google-Smtp-Source: AGHT+IEC9Iq4EaKhYx8qmUbYnuJvccsA4JfuYihpWx87kTUBAYRcJpYOGlPBXGZQc1wJV/sFNjFt2g== X-Received: by 2002:a05:6000:430d:b0:42b:4219:269 with SMTP id ffacd0b85a97d-42fb44ed6e6mr5912605f8f.41.1765636793620; Sat, 13 Dec 2025 06:39:53 -0800 (PST) Received: from egonzo ([2a01:e0a:9ad:d3b0:ec4c:9f30:1dfe:440a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8b8601csm19547827f8f.22.2025.12.13.06.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Dec 2025 06:39:53 -0800 (PST) Date: Sat, 13 Dec 2025 15:39:51 +0100 From: Dave Penkler To: Tomasz Sadowski Cc: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] staging: fluke_gpib: use kzalloc instead of kmalloc + memset Message-ID: References: <20251127101055.8771-1-tsdwski@gmail.com> 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-Disposition: inline In-Reply-To: <20251127101055.8771-1-tsdwski@gmail.com> On Thu, Nov 27, 2025 at 10:58:49AM +0100, Tomasz Sadowski wrote: > Use kzalloc() instead of kmalloc() + memset() to simplify memory allocation. > > Also use sizeof(*board->private_data) instead of repeating the struct name. > This avoids duplication and keeps the code correct if the struct name > changes in the future. > > Signed-off-by: Tomasz Sadowski > --- > v3: > - Move version history below "---" > > v2: > - Add proper commit description > - No changes in patch > > drivers/staging/gpib/eastwood/fluke_gpib.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c > index 3ae848e3f738..2b6ba7882dba 100644 > --- a/drivers/staging/gpib/eastwood/fluke_gpib.c > +++ b/drivers/staging/gpib/eastwood/fluke_gpib.c > @@ -853,11 +853,10 @@ static int fluke_allocate_private(struct gpib_board *board) > { > struct fluke_priv *priv; > > - board->private_data = kmalloc(sizeof(struct fluke_priv), GFP_KERNEL); > + board->private_data = kzalloc(sizeof(*board->private_data), GFP_KERNEL); Good thing to use kzalloc here but using sizeof(*board->private_data) will not work. sizeof(void) is 1 not the size of the structure. > if (!board->private_data) > return -ENOMEM; > priv = board->private_data; > - memset(priv, 0, sizeof(struct fluke_priv)); > init_nec7210_private(&priv->nec7210_priv); > priv->dma_buffer_size = 0x7ff; > priv->dma_buffer = kmalloc(priv->dma_buffer_size, GFP_KERNEL); > -- > 2.52.0 >