Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp375555rwb; Wed, 7 Dec 2022 19:49:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7e2Vg/Qt9Yvpwr8PpXPGt3JVc2gGG1fXp/GKu6CvZn4/Bp/cOYEg8zn4qC5tR+2KdXxp24 X-Received: by 2002:a17:906:b14b:b0:78d:cede:91f4 with SMTP id bt11-20020a170906b14b00b0078dcede91f4mr77938785ejb.764.1670471377166; Wed, 07 Dec 2022 19:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670471377; cv=none; d=google.com; s=arc-20160816; b=e2tLgRD1RGnJuH8ctliMC09UxQh9RkQon+EhzJw5W3hylEQXwatRUiYHSbOdQIumxt z5wVHP2yD6nFulXMJjOg7FhGH4MJ2O9u1hURkfCYTt7xYw8Ggj94uCAn4jUk5RxBRB+p 6hS6lITSxeHBuStcmtqi3omkCk5jsV9B7s+j26p5puZ2tAZZflU94Ey3pQdGJnWu2/W4 Z9chUDZtyeXdQEjvqlf2APyfnRdPOGI4FUHA90hPEY+jOscKOkZIq1LqdwX3htOGDyeQ /Lq6QSdmB/PmT5FxDzC6cianqbqJ8nSEZ0rc9kvqkgXi7xWPA9vK+eHtZXECEfqAvhCj xSWQ== 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=lTBT+Rc3pX9aienEfSUOgyzqv8gdRE6SHUGNOvHpWI0=; b=zzcF9QNghk+YBbyiLREP0d9Uwyv4ik5K+Z9sPKM6eLuEIhtCP1tfswWiFB3NcoHZJ3 wGb1ENmr+FSrkJQvjiwZkyVPzBHa/kNVCtmHYnV+haBp6oJI8zWw3ngaYgmaW3SXzj4u rsb6NsQvyFVAzkvGjEm7JKvSoSTMzVM+J4S0sgj31VBuw5JRZuSO+KYwqzsz2xY3po2w AqNRsncv1j7+QzP3oa8DeJx5e7R1nybl3Z4ggxrvSShpeAyRVgbazqLWZ/5Bsi/biCuu 4YbbUxGatLCXH4iIhXS66SOToHueBD1u8TXeCIKOP0StPl0bujoHmCmJSyNWYqE+sm7U uSpA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020aa7d843000000b0046cdae33434si4915607eds.333.2022.12.07.19.49.19; Wed, 07 Dec 2022 19:49:37 -0800 (PST) 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; 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 S229658AbiLHDPQ (ORCPT + 74 others); Wed, 7 Dec 2022 22:15:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiLHDPP (ORCPT ); Wed, 7 Dec 2022 22:15:15 -0500 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D14DC6F0D2 for ; Wed, 7 Dec 2022 19:15:13 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowAD3_TW7VpFj69+pBQ--.47007S2; Thu, 08 Dec 2022 11:15:08 +0800 (CST) From: Jiasheng Jiang To: robin.murphy@arm.com, liviu.dudau@arm.com, brian.starkey@arm.com, airlied@gmail.com, daniel@ffwll.ch Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jiasheng Jiang Subject: [PATCH] drm: mali-dp: Add check for kzalloc Date: Thu, 8 Dec 2022 11:15:06 +0800 Message-Id: <20221208031506.3211-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowAD3_TW7VpFj69+pBQ--.47007S2 X-Coremail-Antispam: 1UD129KBjvJXoWruw4fCr1kKFyUWFyxAw13Jwb_yoW8Jry5pr 48trZakr95ZF45KrZrAa1kurn8Ca9I9FyxKFykWw15uw10gwn8AF4kKas8Wa1UJrW3Jr1a yanFqF4fZFn0kw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHUDUUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS 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 As kzalloc may fail and return NULL pointer, the "mw_state" can be NULL. If the layout of struct malidp_mw_connector_state ever changes, it will cause NULL poineter derefernce of "&mw_state->base". Therefore, the "mw_state" should be check whether it is NULL in order to improve the robust. Fixes: 8cbc5caf36ef ("drm: mali-dp: Add writeback connector") Signed-off-by: Jiasheng Jiang --- drivers/gpu/drm/arm/malidp_mw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c index ef76d0e6ee2f..fe4474c2ddcf 100644 --- a/drivers/gpu/drm/arm/malidp_mw.c +++ b/drivers/gpu/drm/arm/malidp_mw.c @@ -72,7 +72,11 @@ 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); + + if (mw_state) + __drm_atomic_helper_connector_reset(connector, &mw_state->base); + else + __drm_atomic_helper_connector_reset(connector, NULL); } static enum drm_connector_status -- 2.25.1