Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4462567ioa; Wed, 27 Apr 2022 04:32:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBnDdhdHs3dryZackx19hdZeoaxu3ZxBxwKJcEaOq31V8IVqLN4ORbQqUMAFYnh+hv+CSL X-Received: by 2002:a17:902:b7ca:b0:15c:df6a:be86 with SMTP id v10-20020a170902b7ca00b0015cdf6abe86mr22830824plz.70.1651059149920; Wed, 27 Apr 2022 04:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651059149; cv=none; d=google.com; s=arc-20160816; b=dzgFOfLmaWnTTCIZZyZOAATj7QmldP0+QTiQth4vDrrU1F/xrq2uIJn6thyj2TnFm5 YTQIz71VjPbLMgBu1kvCOPCnT9JpeWSnIJMtQbsvfpw+OGB7TEtVlhIl4BaFfuIsKIv5 fz6/b/8ItL/DrKlDZ6Udr+6jRz0ovf1CaY/nF/CvFpW3j/tkk686HwydEA49O6n+DaJF 5F9/eYZxZghzY8+wUuOPw8tosrw3ubCTs2XhcsRAMcbIGG366meWZFNbb9rwcQN534mn GlN3vOGX15VLkK2paNuhY302cy4vV+hLRbRgTBjThpQNnYtWwzsVdU/abb3A45fLAoEi TD4Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PqozEl3oiHK9sgQsLjj6yLKBdBqSb4x21ZmhCX6lvm0=; b=YjDJ6CgeQowv/J0GfXVWePEgWjWeK5OAwRRhNwOkKCNo/Ux5iHmFdYPIwFILnXm+OQ HDqMf2sI9BnsIEVs3EJUmw0XIdx9VmWOr/iFxi32ufXTs6+Tk+xCsDu/Wzg36e2Gl3pe 5nzJmfxnfmv9DEgHd4lMDjdVEhIcQWHqUQ2rgmS92189JKyMMH9T7uMw+iRHY+5pqpEq 3m+35oD46jO9fvRSwa4snx8X9XajCll1gz0j+LHIo/27v+vuFd0EOfgYHl5O0qmfC01C DJ5D0K2MM9zyOFxcN7DAbuNtqQOqMGR/8B7yN+32NypgnzOAMKCFO99m/MBjAqXwGWUi ha+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mS9MlMyD; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k187-20020a6284c4000000b005061eb330a1si1075598pfd.351.2022.04.27.04.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32: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=@linuxfoundation.org header.s=korg header.b=mS9MlMyD; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CBB9F484D3E; Wed, 27 Apr 2022 03:20:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346465AbiDZJLE (ORCPT + 99 others); Tue, 26 Apr 2022 05:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346944AbiDZIuz (ORCPT ); Tue, 26 Apr 2022 04:50:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5CE17047C; Tue, 26 Apr 2022 01:39:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4C713B81D0A; Tue, 26 Apr 2022 08:39:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59930C385A0; Tue, 26 Apr 2022 08:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962353; bh=rgM8kfe5zD9EZNfO/4CiOhR5Q/c5QFs9MDQG24jIl1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mS9MlMyD1rqeWzInphYDBuyIq9AsWkfbLVWHJP0MBndFz7DjxtI7awdeFWDHLlwpl kRj7XO65daZnToXg0IFT+SozWlA5PeYRjWIt5JYf8l2fbTV6f+KWo6uec0wxZ0CMfH vROjUdcGpqBp82SgZM7Wsh9okYUfsG7VKdP+FA2U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoke Wang , Dmitry Baryshkov , Rob Clark , Sasha Levin Subject: [PATCH 5.15 066/124] drm/msm/mdp5: check the return of kzalloc() Date: Tue, 26 Apr 2022 10:21:07 +0200 Message-Id: <20220426081749.177593375@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 [ Upstream commit 047ae665577776b7feb11bd4f81f46627cff95e7 ] 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. Besides, since mdp5_plane_reset() is void type, so we should better set `plane-state` to NULL after releasing it. Signed-off-by: Xiaoke Wang Reviewed-by: Dmitry Baryshkov Patchwork: https://patchwork.freedesktop.org/patch/481055/ Link: https://lore.kernel.org/r/tencent_8E2A1C78140EE1784AB2FF4B2088CC0AB908@qq.com Signed-off-by: Dmitry Baryshkov Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c index c6b69afcbac8..50e854207c70 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c @@ -90,7 +90,10 @@ static void mdp5_plane_reset(struct drm_plane *plane) __drm_atomic_helper_plane_destroy_state(plane->state); kfree(to_mdp5_plane_state(plane->state)); + plane->state = NULL; mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL); + if (!mdp5_state) + return; if (plane->type == DRM_PLANE_TYPE_PRIMARY) mdp5_state->base.zpos = STAGE_BASE; -- 2.35.1