Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2127417pxb; Fri, 25 Mar 2022 11:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsNpuLW1EG3Uv7YmLR6Mi3zq9GE8s71LdGWqgznfEWpF3cJQRa+j6XhEMCDp5dPFbSUbNT X-Received: by 2002:a17:90a:7f04:b0:1bf:9e71:9d35 with SMTP id k4-20020a17090a7f0400b001bf9e719d35mr25848508pjl.203.1648233230999; Fri, 25 Mar 2022 11:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233230; cv=none; d=google.com; s=arc-20160816; b=COP5W51LWfkQYHHgDwvrVInWlmzC4znjUgM7RHDDQGf2gHYz18ZzbGoo6JuOtDcKdV ueUSk+IsAam78Gb9KJJtzXUWaTOuCr6FzIDKQtReTQAQK9jpHvfA25+W2n1X9s5JNneq RcZnGzL6JQY535M+QTUNmV3hAPCzU00kA8UZTYfZ0fZbV1krJlNGfiNd4O6h9jO76Ss5 7KgXJTMeVIr0+yPLxmI0NveOzoe035vrec6uXNRNgxh3S2IExlPXaEoIRVG8FjgyyPW9 W3Pb/6fniC0bMEaAcX06qCGtdHHzJLNMr6yJKpkuHGP0JbgjGTz8jnK7mCL8B1EcHpJ/ Rk6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=mrbgLvlsjdW9rx9HY/2WDm9oF7weTNiBspzAy++1AVA=; b=KmxtEscvCAckg3M/5h4CvDt+dBEhNr5dYI3Vv4zsn6rPNgooSo97S83xoGwwQYgSFa IPmrWd3CtN4rKZAaHndUU6dpJC5FkrbbY8O6Pw23gZw7f1gbYYLJRnxi18up3bjZE/2b F+ifv+mmhyUOio33hDUTx2N5s/SDA3MEPzdlWTKZaseGsIgGTiZOr95AXlw2xWnK45Xk LUeEGIVyUzV8t8DywtqHp55rrpkD1yHyi9V5McfoenwRbsKzfd1V3btrV5tBSLgbJHdh dnX6Uw++nlLoBoyFSrGhrGv7HEz0kk47/yOXc4HoNVE94Tq4yVgNOOoqpISTOGw0W1Jd tOvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=TzTFHEZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m11-20020a170902f64b00b00153b2d165edsi2958917plg.501.2022.03.25.11.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=TzTFHEZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 48E7B6E569; Fri, 25 Mar 2022 10:53:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352417AbiCXR76 (ORCPT + 99 others); Thu, 24 Mar 2022 13:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352437AbiCXR7z (ORCPT ); Thu, 24 Mar 2022 13:59:55 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF9D45789; Thu, 24 Mar 2022 10:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1648144701; x=1679680701; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=mrbgLvlsjdW9rx9HY/2WDm9oF7weTNiBspzAy++1AVA=; b=TzTFHEZOy8FoYnN7HPs5eNBpL/c0bgZ38K8K5Fzms63fSVtWRD0YQOu5 sFTzs5N9tDgDyxeYACb7/FOwXXaIACJQ8FtBmg9Z24x4yUxlAfM+FfPMy EKha75HVH9qHXoQdvin2BKXMPiWexH/5k09I8IIPcWxCVJSxhzwe7WwkK c=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 24 Mar 2022 10:58:19 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2022 10:58:18 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 24 Mar 2022 10:58:18 -0700 Received: from [10.110.52.81] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 24 Mar 2022 10:58:18 -0700 Message-ID: <4a23c6a6-737a-c910-588b-8d4827d9560c@quicinc.com> Date: Thu, 24 Mar 2022 10:58:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] drm/msm/mdp5: check the return of kzalloc() Content-Language: en-US To: , , , , CC: , , , References: From: Abhinav Kumar In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 On 3/24/2022 1:36 AM, xkernel.wang@foxmail.com wrote: > 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 Reviewed-by: Abhinav Kumar > --- > drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c > index c6b69af..5f914cc 100644 > --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c > +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c > @@ -90,15 +90,18 @@ static void mdp5_plane_reset(struct drm_plane *plane) > __drm_atomic_helper_plane_destroy_state(plane->state); > > kfree(to_mdp5_plane_state(plane->state)); > - mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL); > + plane->state = NULL; > > - if (plane->type == DRM_PLANE_TYPE_PRIMARY) > - mdp5_state->base.zpos = STAGE_BASE; > - else > - mdp5_state->base.zpos = STAGE0 + drm_plane_index(plane); > - mdp5_state->base.normalized_zpos = mdp5_state->base.zpos; > + mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL); > + if (mdp5_state) { > + if (plane->type == DRM_PLANE_TYPE_PRIMARY) > + mdp5_state->base.zpos = STAGE_BASE; > + else > + mdp5_state->base.zpos = STAGE0 + drm_plane_index(plane); > + mdp5_state->base.normalized_zpos = mdp5_state->base.zpos; > > - __drm_atomic_helper_plane_reset(plane, &mdp5_state->base); > + __drm_atomic_helper_plane_reset(plane, &mdp5_state->base); > + } > } > > static struct drm_plane_state *