From patchwork Sun Jul 23 06:41:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 124423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1146213vqg; Sun, 23 Jul 2023 00:41:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEFtpbWZRHGaeY1HCX8mbZpO1KRGJmOw37kjnsyCh1dm889MFPhhdJZbjQ5byl73F5jY7/ X-Received: by 2002:a05:6e02:1be3:b0:348:7d72:6371 with SMTP id y3-20020a056e021be300b003487d726371mr5070241ilv.2.1690098082272; Sun, 23 Jul 2023 00:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690098082; cv=none; d=google.com; s=arc-20160816; b=oWJYhEXYHNsK8IqUk1G6+IHgs4BQkvuzRxNyzy8fELoMQNEJFJCVSqOkDwE7eswsKz 01tuccSW/Q7uW85kEmmKvUx9Lc4pQ80NQ5UMwjG2njsyqhDyE98i0wro9ggbji8SGSv7 FTc8FfJkKXfJhAmD1j6v7hJx/5jQTF8qj7Q1WdYfXvf7xfgFunbF+W+W62Wf90/zAAgy ns7CeYV4RVb6Qbl3+ASHp61goWHGJOynAE+pnAih8prNdkNiOtXbnMRtBdU05e7FFd6w 5BbmFDZWHApmixptAOCSmeRQ6g6tFgZuJagoDCARYUsrBpcB0aRGpDEjf0CSivvMudoy cReg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Q7o0UQvRfkS/4+Mc6nSPTzH0IapT9/fEsaA6pwimGA0=; fh=3GvWnn1jLuvtC+vi0YekMY6dPkBpQzB0p57AZGcUCuk=; b=zsPRQZMtVF+wrXSzUlsiQplpj4qfi28bmmrU/P6y5q+821oCvUfL1/iUy+rbEIdjKH 9AydR1ALNXurRQtN4zWlydTxIKBalWy//hcvLGGCcxFLkY4IE+9/50tNgv6mLsv7op6b bPsnnQXnUr0Ni2wtGukvwNFPMIxFMMnGf9pp6CIT5IilZHiTu7G6TJhYM43vpEY1NXBH eCiXaiPYD8VshNNS1rHlumKAIwz9coDQJ8+Z4N//Cohrd7mzuSrXPJoaJq/4YXYaYujq IBwQZ5l52gI5zCwf/HE/2F0Q4rEdkphGVO7UIJ6OERRizcT/uFhdx4L5PpTkkCn7V1kI ng9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="N/o86135"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a170903228b00b001b9d2982362si7368138plh.36.2023.07.23.00.41.08; Sun, 23 Jul 2023 00:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="N/o86135"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjGWGln (ORCPT + 99 others); Sun, 23 Jul 2023 02:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjGWGll (ORCPT ); Sun, 23 Jul 2023 02:41:41 -0400 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC0210F8 for ; Sat, 22 Jul 2023 23:41:40 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id NSmdq59F14DtINSmdqfFoy; Sun, 23 Jul 2023 08:41:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1690094498; bh=Q7o0UQvRfkS/4+Mc6nSPTzH0IapT9/fEsaA6pwimGA0=; h=From:To:Cc:Subject:Date; b=N/o86135ANjyjKGmokuS7xBDhOlV15gvy89zRuss8Qpd7KKHc/I4AvMRy0vHpTNPP CdHlSFsd+qtazyI5QGlhGEa7t2s+ezl1Wb0N6mE9oRHSoYuvUBlBdxTuuwctbFxR2A 9Zk5/e8z356kbKZSdmRnh2veOy8ewV5V48lDUyg0xuZHjeRIA/sxilDnSt8F7xqOnf 4DmDV+b4GJow+4SNILdEJP+Bla9fs59NxWl1NOK80l4LU2T6INRhrrsH+zD1gGPb4e 3J3PTblIWoQEMzg6a8hURf62+DuwkL5YE/vJoHpuj+ZKimoSeJBJVwoZCInRtvdcx7 t0prBJ/xef2wQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 23 Jul 2023 08:41:38 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH] drm/msm: Slightly simplify memory allocation in submit_lookup_cmds() Date: Sun, 23 Jul 2023 08:41:33 +0200 Message-Id: <9861e8b1ce385a556e0c9c4533beee9c4a92809c.1690094459.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772196286525768663 X-GMAIL-MSGID: 1772196286525768663 If 'sz' is SIZE_MAX, kmalloc() will fail. So there is no need to explicitly check for an hypothetical overflow. Remove the check to save a few lines of code. Signed-off-by: Christophe JAILLET --- drivers/gpu/drm/msm/msm_gem_submit.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 3f1aa4de3b87..6ca8f8cbb6e2 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -211,11 +211,7 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, sz = array_size(submit_cmd.nr_relocs, sizeof(struct drm_msm_gem_submit_reloc)); - /* check for overflow: */ - if (sz == SIZE_MAX) { - ret = -ENOMEM; - goto out; - } + submit->cmd[i].relocs = kmalloc(sz, GFP_KERNEL); if (!submit->cmd[i].relocs) { ret = -ENOMEM;