Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2071660pxb; Fri, 25 Mar 2022 10:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGRi9BqtIFzs1X9Cjz77cmnHlTbrRp8raPqvLinGQfLpA+jdyCnr3QLYJ92zi55fJ2D79l X-Received: by 2002:a65:6e09:0:b0:380:4723:b4e9 with SMTP id bd9-20020a656e09000000b003804723b4e9mr557170pgb.346.1648229669469; Fri, 25 Mar 2022 10:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648229669; cv=none; d=google.com; s=arc-20160816; b=MMI95niY7dDYioThO4Zm2AYCCKjZFMOdedR4Wcrsu/fyzjshgXR7D2JMu7nVROn6EV ez/Rhr/THm3ZdygBkF7vGMtTZTmFzBkMYyuxiSnrT9J5dSZ7fZBtVWxQVN3SqlYPnZm5 ZQ/zmAnjGyg9qLGtSYNg4cxtzMCBTD9GlWbLWA0TaWKvwBpwknthXnaWTqrvikf/Nw0p lGv4UxPObRyCjO7xEDFpVoIlDj7yyU1xHsZnGnv5h20tF1qcWmRMnvXex8Kly/qFsYVb q3lLJM4SHoZZjWVcSnntanVQJHmakuwB3mO4GVBKvKxPE79z+X6Ycb7BeT4vQ4uQF4BC dZYA== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=fjYplXUxWwaBwzbAUquO5tJoKkhAeRwrA4rqKKHb394=; b=HbBz9uQvznDGKQxAg2MxFPDb43fwFIZHU1Xt/PQO2TvQTNT/QpRaS1wcrD3bnNvUUi rJl4KmHVpzNfVV3GqUK//E1Oz+yPersDe+TEO8gFWTqsN1gcSCYEtS+hFFdv1UfT+sdA N6GfkvZDsWBke7ij9+m0+bLLVXEX+Sa7FvGxl01IFb9Xu/eusCsuH4QD3CJ7banSZK7p CBA528ZJ3tR92DXmyM+gCosKwutCga63wcOpWS2SYFb3Yy+6UPXeZoRXFZNUEyslHl1C krwBEp7ENTdko8OlGkbT0KFQG4hIwP2KG1BDjXNidfVhmA8UoBx4JTCg33hMjqIYnuX/ VFNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=tpnVkexj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y16-20020a1709027c9000b00153bcaa4897si2779431pll.86.2022.03.25.10.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:34:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=tpnVkexj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C7EEEBB9A; Fri, 25 Mar 2022 10:23:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242950AbiCXGpS (ORCPT + 99 others); Thu, 24 Mar 2022 02:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234676AbiCXGpP (ORCPT ); Thu, 24 Mar 2022 02:45:15 -0400 Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5113C8FE5A for ; Wed, 23 Mar 2022 23:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1648104218; bh=fjYplXUxWwaBwzbAUquO5tJoKkhAeRwrA4rqKKHb394=; h=From:To:Cc:Subject:Date; b=tpnVkexjRnMfYpFKUhtgqGUmbdgu3AARWe3utbEChJ/X6HX8A6GQR2EaYaTyR1gw2 fSfSqOaJ0eZxZZ6s1cCZ/7wqjjYYHJl+obZM7Ya6iYHysQWS/4dnPxKtPjydCxH3It 8DK6Pzq/rHED8xlPRZ8Z7dKCYy8xBuKOG8tur+dI= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrszc8.qq.com (NewEsmtp) with SMTP id ADD0A0CE; Thu, 24 Mar 2022 14:43:29 +0800 X-QQ-mid: xmsmtpt1648104209trrbo5h6n Message-ID: X-QQ-XMAILINFO: MB5+LsFw85NozOAi+JJCABGcHmzsemUO/GRu6RgZ2QzoD03us3gthe9Ml9fTkt t6r2nv/I/gmdkKmp9jHey7E3O+SKG46MKY4/HjPYEu3T49iDan7Z1Ur26WU6Etfwz1N4GIfgnyK7 WG6LL7jckq60jdclWh9Rn5NxroJ/641aeEjxwPPmTciDXD7ON2ln0/GaKzqVguVILlmWNk700vy6 9K9umAZBonInWLeYHRx2gWsgavHDjcppBlj1vvc092v/OxFAS/r/BqWCqR3mXc+10e/0JuSBVtbO fGZ8iIdPfI2uARW0/bgpRZa12JmcSw2+ZcrSJSGjbXogFNS9HTZGXkeB/opKwIhfJw5MPzP2BOCc QH+1byIm+LLpBgoN4Q0Aa5HaHB0UhmERf8qGxllIHi3RCcodXx1aNB6evtFvaueRyCHKA8Id0Mqx Hzfee2nKLx52jWGzsqAqU2qSQpqZszupm6Gj6lszYURe/d/asmhxSq8hJYudqCeaG39qqMlvpJ0e v11X5WAf/1KvOfW5N6Sbny5c8p4fWpOCM/oN74OtqTOI5GioTWvm6h+2WOxOTM0GV1rBP/URb6W/ 34T1EGaXXsIBQf5vELHQc95AXy8wUWebTMfpTrs5cH8Jw1Jd8/Fz59zoO05ipZZcO0bbvd0BPJWU qWnzMZ1H90/e7Lzi/fvElTNsRiFTQ5hActHA7XP+zSlgeOLVn7jpUn5Cl7Xl43bJkCV9fEAMHal5 SD5hJtnAgFwd8PoEeTltbitA6PsfyTI3vwaSOHUX7BOqmD6eH6z99imx8UeoRhom1G8Rkt+9gpLl RRN/sMjP3HDrbf2rFdyHW3qr57/JKqlCQXAYzdehl6xyW0GP3+UWQkvM7CFGJ8FMTZQ6cT3BNW68 pk6kLtPL1gFqKCjSVQ58yILwLXQsCPkbjgOjLqzwtViw4uwo00AOafNZnYoA1P6CnHGeSk52Q2XA dT7w5Tt06O22CjoI6aAFHucXfX7vZnaVkF8RLeuLw= From: xkernel.wang@foxmail.com To: liviu.dudau@arm.com, brian.starkey@arm.com, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] drm: mali-dp: check the return value of kzalloc() Date: Thu, 24 Mar 2022 14:43:17 +0800 X-OQ-MSGID: <20220324064317.2424-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Xiaoke Wang kzalloc() is a memory allocation function which can return NULL when some internal memory errors happen. So it is better to check it to prevent potential wrong memory access. Signed-off-by: Xiaoke Wang --- drivers/gpu/drm/arm/malidp_mw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c index f5847a7..0720b21 100644 --- a/drivers/gpu/drm/arm/malidp_mw.c +++ b/drivers/gpu/drm/arm/malidp_mw.c @@ -70,7 +70,10 @@ static void malidp_mw_connector_reset(struct drm_connector *connector) __drm_atomic_helper_connector_destroy_state(connector->state); kfree(connector->state); - __drm_atomic_helper_connector_reset(connector, &mw_state->base); + connector->state = NULL; + + if (mw_state) + __drm_atomic_helper_connector_reset(connector, &mw_state->base); } static enum drm_connector_status --