From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 408FE314B70 for ; Mon, 24 Nov 2025 16:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764003429; cv=none; b=Xl7uaPfADbc5JL748of0QU8nfiiwiJusDOGIrK1FnwPdTnjEEV9NFK4IZmPuWtGhcmavST6/Mt5nT7Y9N39YaGQZoHYUeLh05iveYyO0qnzZcBV/yIxwHQaBvBObDl0aoTWVAr0NKFoZIyMvThtkqfbM0qEU/VHwW+BeHpavduQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764003429; c=relaxed/simple; bh=PfQ4/7NQzFSfsv0ka8gSJEka3ONlJOdaGwYNL1BLIPQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=huxAKDIuPeUbje0u6xwYfw2Qrcj3viWaG5n8bbWKnXXPfJJb/ARupsjsqrJWCXGePxCgInSGo9cf660YCD/BQEW7zFAl4Om5cc8raZZzgfpQl5cxgyetqRHC77CNOn11Ot0XalH4aN4nV8Svx0xJCqWxTwOg75A0/ZlzdevBv9k= 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=AoT+zpg9; arc=none smtp.client-ip=209.85.210.179 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="AoT+zpg9" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7a9cdf62d31so5562533b3a.3 for ; Mon, 24 Nov 2025 08:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764003427; x=1764608227; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qUogX7WY7Vd//7PtUJR23B9zmXu2YytI3dxf/G/KQjw=; b=AoT+zpg9N/EFVj+whQXkxWcrTuQdXOhb7bA6WlBpaPnTbVkODqoeLkGp4Sf0uw3mlK OKcD57pLpKEIlFtww0ftE0BgEwAb/oJwYbOolEdtrRYk6uVTxeD7y5nPzzXR3C4qxeXp ygnBIQ49HZlvwDBofadlr2MUrRO62upoZ+QLu8Oa+cDXvlY9A29/7JwfVWhVlRyFYXG8 zVDP2Y+B5pb3FsOIinKx3acFtfvzMhSkIfrX9hZkI8YiryS3X1XoNAE0+cxPqEJixsiT 7aRamHMHD7VX2C9gYkDZCRO/Kbcz2TfoQXBv8NvyGt1M3PQ1xcBZPLnWWGNBxtvmYK/a AuVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764003427; x=1764608227; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qUogX7WY7Vd//7PtUJR23B9zmXu2YytI3dxf/G/KQjw=; b=KNbDQSnswhgoly5L538p/wWph1y/at3kqqcEtdO3k5KTmHXlzBzqxch5nqIQex1m8v D5GoKprTxr5rYG6wdDlC6i32qyus61h/sK9YMKTZHKnf8+n3RqMYBILZ5NI8PEGU/wi4 O5CnWP+Pcz/XClVdynADhdK1EyIOq7/OdlKOLrdxfKboTHyrJzpAgHsYNVYF+/eI9fPk 7q8yB+KaE+HDaIW6QMWwMBGWb8ugJnMnrOCjujgjK3Tu+iQx3ZaR/lNVrNzEyHACJKwt pN5mS574v3ov7bifsj0bDmiAd/CT+BtcTbwAU9j/iFNMHAugsYpurPcEJPnW4/qEN3RX Xrrw== X-Forwarded-Encrypted: i=1; AJvYcCVcpTo4fT+Y/tuddc8Bk7PlxhWMlozvbWTCM2vuJtq/3ZfcC3jFbqrrxQwDa1xFUPRVxSmCweGAbDGOz8Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzitTKw/PnXa/UrDq0K94hzn6e2Vacb7IqwJjwaiD1zH5NnBXD5 ag9hyZop/dx/uOrprbbPJIf5yZCcf0uiRvJ7FZ1uoTHEu3wbI5ij7+n9 X-Gm-Gg: ASbGncsI5z9P7cYcqec9KEif0SRJx1aQ4fjxRkRwzIzAWCnU1s+qzJ1E1Vo68mwNUwg X9wylltcyJa3ZbEYr50bhl/hMkV0q7/RHiVkKpEKvslqxVnTRCSFFouz6t51TsBQ5E/pGPSKIBk rR9LAuiOvF8le2JEft7AT1YFBc3aARJgHoxv86gCarkP0AAD2fOthH+ojXKWTvzgF0JiR1Ypogv 2Bzknn2Ly8uFnuhEYMlE8OzXmY5VhKHcJRfyUoB/gFz242Tgh0rFbWPD2uIVDxz2wZh72nSjgkS Wk96ymyu2MeeSYh2hij+B+dVdIiKJSUs0hXFEyGzhyon/PdCPdgiReVMPDPYJIbIhLmMdV0esfW xoE7zfHetyWlL1/swbbPeAToenGNzdxR7BIB6T/oKqh7aenWd5xNugrfrjMBqbIBJPL+E9VraNP NSWdr0sjyRGPMjbME5skxneT6A8CUoQogVYo8= X-Google-Smtp-Source: AGHT+IH4bMrzvbSCDAu0Nr2SVYvmh9S6c4NfxteJlssoS6WoKkg6ffShHh1gjfGea3W559MOrwbA5w== X-Received: by 2002:a05:6a20:12c2:b0:341:5d9f:8007 with SMTP id adf61e73a8af0-3614eea27aamr14043297637.57.1764003427338; Mon, 24 Nov 2025 08:57:07 -0800 (PST) Received: from [10.0.2.15] ([152.57.124.34]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bd760fafe57sm13738935a12.33.2025.11.24.08.57.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Nov 2025 08:57:06 -0800 (PST) Message-ID: <2e697dfc-2575-469c-9ba2-4470db34b5d1@gmail.com> Date: Mon, 24 Nov 2025 22:27:01 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] scsi: Prefer kmalloc_array over kmalloc involving dynamic size calculations To: Don Brace , "James E . J . Bottomley" , "Martin K . Petersen" Cc: storagedev@microchip.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, khalid@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, cassel@kernel.org References: <20251007065345.8853-1-bhanuseshukumar@gmail.com> Content-Language: en-US From: Bhanu Seshu Kumar Valluri In-Reply-To: <20251007065345.8853-1-bhanuseshukumar@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 07/10/25 12:23, Bhanu Seshu Kumar Valluri wrote: > As a best practice use kmalloc_array to safely calculate dynamic object > sizes without overflow. > > Acked-by: Don Brace > Signed-off-by: Bhanu Seshu Kumar Valluri > --- > Note: The patch is tested for compilation. > Change log: > v1->v2: > Updated commit message to refelect correct intention of the patch to > address James Bottomley review in v1. > v1 Link : https://lore.kernel.org/all/20251001113935.52596-1-bhanuseshukumar@gmail.com/ > drivers/scsi/smartpqi/smartpqi_init.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c > index 03c97e60d36f..19b0075eb256 100644 > --- a/drivers/scsi/smartpqi/smartpqi_init.c > +++ b/drivers/scsi/smartpqi/smartpqi_init.c > @@ -8936,7 +8936,7 @@ static int pqi_host_alloc_mem(struct pqi_ctrl_info *ctrl_info, > if (sg_count == 0 || sg_count > PQI_HOST_MAX_SG_DESCRIPTORS) > goto out; > > - host_memory_descriptor->host_chunk_virt_address = kmalloc(sg_count * sizeof(void *), GFP_KERNEL); > + host_memory_descriptor->host_chunk_virt_address = kmalloc_array(sg_count, sizeof(void *), GFP_KERNEL); > if (!host_memory_descriptor->host_chunk_virt_address) > goto out; > Hi, I just wanted to check if you had a chance to review it or if any changes are needed from my side. Regards, Bhanu Seshu Kumar Valluri