Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp84187rdh; Wed, 22 Nov 2023 19:34:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgcWv4Rs8/50ym1p5ui7uo/j23SIiAjqiOdbkJQ1PpsIb+yL4pD3gopGFLllEViEyvP95T X-Received: by 2002:a17:90a:1d9:b0:27d:24d6:7343 with SMTP id 25-20020a17090a01d900b0027d24d67343mr4251780pjd.19.1700710449639; Wed, 22 Nov 2023 19:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700710449; cv=none; d=google.com; s=arc-20160816; b=xfWltGR0hLH2/xz5Tz/QblF2bLDbdDTVjdyTZvqmg3AXtB33Dm39RRpy722vFlD7VS dUWaIA2keB+NsoskBAE2F8Md6G4GWiVvhpFkGiyGgjvWtGc+Hed7w4Pq0b/DoUbraE4Y FsWmFNzvgATz9u6yv5Wv06M2aJ71qDaFIRHfmH9NXKrReBWtWPNVy9WbulUatMrXNlpG sGxHbQH0wYp3+tdaEl4j6GoMMmoX4ra1z8tyVRVfq0PnYivsoifQdleFPydP2hyRlOmX 9a4eMpZiAusEwrLfEzCBl64l52cFWNhfFT+w8KsnfmU0BAjHkqOXyJalch9tEJkvPpex 3KYA== 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; bh=cru8zvoQjJolL0I0pjHwY7MKawfeacTv/M6CmZkirjY=; fh=7hCOwRo43d4yPGMyEllvtg8/56ZYSfkGD8MEkfPsbb8=; b=wwYP+/cMQfu8c1rkJWUL4PqBy8K3PBBngoZXODYJV9DjDabHhRuHlzulW575Bb5VDL k+TtQ7qtzEHS1EioeZjaVzU8uYITg0a2c8lE3JDuPQfFNJ3OLvd40iueOPXswzKM8zbm WB51kAU7MBdDc0/eaXL+5ZbNyKbqP2C8U22vYnCBoietb+uM5mP62milW1wMlZHepOTV IzwX/vzimL5BMDjKIiRpWKJtZx9ODIMiND6El2VKhBd+nMwO062TT/c0oVXY/3POwDpC 7lSNNpPQdW1lpwGfLtYN/7evEUjSyTPrEeN3cq9eY+CLswu13yOg/cv5ICKowGxkHkww /usg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id hk8-20020a17090b224800b00274d3f62044si492220pjb.111.2023.11.22.19.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:34:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 82DED8235BA8; Wed, 22 Nov 2023 19:34:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232915AbjKWDdw (ORCPT + 99 others); Wed, 22 Nov 2023 22:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232584AbjKWDdv (ORCPT ); Wed, 22 Nov 2023 22:33:51 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2876199; Wed, 22 Nov 2023 19:33:56 -0800 (PST) X-UUID: a4cb450929be4957b020d6d1885e0822-20231123 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:31d8fe63-6051-4232-9283-7126707a066e,IP:15, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:25 X-CID-INFO: VERSION:1.1.32,REQID:31d8fe63-6051-4232-9283-7126707a066e,IP:15,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:25 X-CID-META: VersionHash:5f78ec9,CLOUDID:583a6160-c89d-4129-91cb-8ebfae4653fc,B ulkID:2311231133474R7T9XYL,BulkQuantity:0,Recheck:0,SF:19|44|66|38|24|17|1 02,TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: a4cb450929be4957b020d6d1885e0822-20231123 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 591889600; Thu, 23 Nov 2023 11:33:46 +0800 From: Kunwu Chan To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, marijn.suijten@somainline.org, airlied@gmail.com, daniel@ffwll.ch, jordan@cosmicpenguin.net, konrad.dybcio@linaro.org Cc: kunwu.chan@hotmail.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH] drm/msm/gpu: Fix null-pointer dereference in zap_shader_load_mdt Date: Thu, 23 Nov 2023 11:33:29 +0800 Message-Id: <20231123033329.27477-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 19:34:06 -0800 (PST) kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity. Fixes: a9e2559c931d ("drm/msm/gpu: Move zap shader loading to adreno") Signed-off-by: Kunwu Chan --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 3fe9fd240cc7..0ebf86ffd57b 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -144,6 +144,10 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, char *newname; newname = kasprintf(GFP_KERNEL, "qcom/%s", fwname); + if (!newname) { + ret = -ENOMEM; + goto out; + } ret = qcom_mdt_load(dev, fw, newname, pasid, mem_region, mem_phys, mem_size, NULL); -- 2.34.1