From patchwork Tue Jan 14 01:12:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Heng X-Patchwork-Id: 13938273 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 ADF2BB673; Tue, 14 Jan 2025 01:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736817192; cv=none; b=B9iT4jDl/4ovzstpjlruBwHg8wDOCZT48XHII7sg43R8PfUdpKmkWHTl1FDqFBYYRPJ8ktKVcKmcFVPEEH/Wgy8e1NuKBWt2PQHvLRjF2vnB6lhEUFzWFcttuk9ikC2NBBBg49Fqr1vv/WceSpJQ9gNh6Nfn1THwhqUK20s4k78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736817192; c=relaxed/simple; bh=HbHrVvZBnbr/i3q3nkvn2hSYq8SO0I+oKyoYDbLKgfg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FHI79KYggBm6olmrIcUNruBl9jU2R+vKq3/Fm88cNKVwltTH7YJ/BLnNUbpEe3G04rC1N/ypq5WsLJXsL2vNMfODcl47OpzUxU6Rq2DqRsFZbb4VmKLtCYtw8EiRQl9Tb+oUGdA3VRW2OOHmot49OdBCrY4Uf3fdgKR2hdSCzxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: b28359a2d21411efa216b1d71e6e1362-20250114 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:1d7d9fa7-5b65-4399-9124-e068c72c91c5,IP:0,U RL:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:25 X-CID-META: VersionHash:6493067,CLOUDID:2ec8a3fe387ac3127568863c22facb71,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0|50,EDM:5,IP:nil,URL :0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SP R:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: b28359a2d21411efa216b1d71e6e1362-20250114 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1370343438; Tue, 14 Jan 2025 09:13:00 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 88AFBE006100; Tue, 14 Jan 2025 09:13:00 +0800 (CST) X-ns-mid: postfix-6785BA1C-2765994239 Received: from kylin-pc.. (unknown [172.25.130.133]) by mail.kylinos.cn (NSMail) with ESMTPA id D6EC1E006100; Tue, 14 Jan 2025 09:12:59 +0800 (CST) From: Zhang Heng To: mkrufky@linuxtv.org, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Heng Subject: [PATCH] media: usb: use kmalloc_array() to replace kmalloc() Date: Tue, 14 Jan 2025 09:12:55 +0800 Message-ID: <20250114011255.871225-1-zhangheng@kylinos.cn> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use kmalloc_array() to replace kmalloc() with multiplication. kmalloc_array() has multiply overflow check, which will be safer. Signed-off-by: Zhang Heng --- drivers/media/usb/dvb-usb/cxusb-analog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb/cxusb-analog.c b/drivers/media/usb/dvb-usb/cxusb-analog.c index 8253046cd6e6..3bbee1fcbc8d 100644 --- a/drivers/media/usb/dvb-usb/cxusb-analog.c +++ b/drivers/media/usb/dvb-usb/cxusb-analog.c @@ -817,8 +817,8 @@ static int cxusb_medion_v_start_streaming(struct vb2_queue *q, * doing a large continuous allocation when (if) * s-g isochronous USB transfers are supported */ - streambuf = kmalloc(npackets * CXUSB_VIDEO_PKT_SIZE, - GFP_KERNEL); + streambuf = kmalloc_array(npackets, CXUSB_VIDEO_PKT_SIZE, + GFP_KERNEL); if (!streambuf) { if (i < 2) { ret = -ENOMEM;