Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp629085pxw; Fri, 8 Apr 2022 17:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypChMIQnCy/puqeAzQQygLvC7Njf2xvgh5rT6ggzMna3APAuXWLS+GVtk2u86f45Xcazj9 X-Received: by 2002:a17:907:720d:b0:6df:c57f:e2bc with SMTP id dr13-20020a170907720d00b006dfc57fe2bcmr20388531ejc.345.1649463568890; Fri, 08 Apr 2022 17:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649463568; cv=none; d=google.com; s=arc-20160816; b=z7SSyiKXwOlhlJ4XzrElrqc9PGLxRi7weOX3MVM+s4KFBt/5yYJ7eByHtfvOeJTOT3 qVgAPavELl9qMrwRDqduDfQ+EgcKYgNNIwEu7GL586UwDppkIu07f5lUzbK6CB/GTbzz z1gsp30Lq7NhBS9QnCloNXWWvjk9LVX0tWeFeECjctfXdJI24uHTI3HzKYsuqCxsy6mg 1G+GuTbvLYr0FLwo+Azj9Eqtfxhmtc2DVdNe48+mPTEqOTffL1rEu2qw6wWAgj6tLrom A6HzVumYZJsdgYazdpJIwqbFZHKAaCLDTlRtLyftU24tN9ZbFZDWcx9niQ3RDnOoVLSg AF8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+/BWz3Pk8r30Gfc4qGV4ZOyYfEY0sq1wDYCw1e9kQ38=; b=yAsiECrHDeGEiaYNIK5FmEx6bwnpechXONVgROW0c7RGEFffDTP43pHOXZah7E3qma CjNouKBTO047emflUhFB56/AS73mdvYG2bAlajYzpQLcF1qNp6AUu6jNLGcCcEtN/PlS pNnQEUi2z1eAvRQdgDOrkOuw0TeyO1uWu1SilmAmwoZCAKsOhtjc+x5hQjP0Z5LIKXaC sGc//5y6C0OV1WrIMy7i9RvMyUArIwcAQ8E8WYPLT7E9lpw0Lfr8fqk/MqRuwNy9iafw u59e0D/jom4vu2V3XQSeUWBmifwkwcRUoUjH4pQQaFBo5B3Zl3fMevMr0UXSjjAIvlNQ VObw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K+SFu/xA"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a1709067fc400b006e0f9bb12a5si1022306ejs.253.2022.04.08.17.19.04; Fri, 08 Apr 2022 17:19:28 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b="K+SFu/xA"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235543AbiDHMX5 (ORCPT + 99 others); Fri, 8 Apr 2022 08:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbiDHMX4 (ORCPT ); Fri, 8 Apr 2022 08:23:56 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 235F633D0F4 for ; Fri, 8 Apr 2022 05:21:53 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id j21so10580185qta.0 for ; Fri, 08 Apr 2022 05:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+/BWz3Pk8r30Gfc4qGV4ZOyYfEY0sq1wDYCw1e9kQ38=; b=K+SFu/xAxfSv8ptmfSt0vivA6W2FAX95a45VvUQlpVTHnKOdxmllKplZItjMf+HOQC 9DYIktpng9TB25OnHxCrL64xd6fagaJZqoStF5Wx0Hy3ikDlXsYpsImSLq3jJX7NTozr jtJAtIG8hw7MQ1aH37SBKuyIZgS9cGBl6TipnChp/SytE1xsSgwhG4Uzcr65ZrCPcP+H sAhYViuQqi8e3dsmU1FBooELOGstjUC1c8KwpSr76ErlET7J3vbBGnI1/nfA4XuHLqHU HNG9mVm9fFu/DvOkx0m06XL6cqKui8Sturp1GWXhuphbUv9x0d4AJRfHRzn1njbuw5PG NScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+/BWz3Pk8r30Gfc4qGV4ZOyYfEY0sq1wDYCw1e9kQ38=; b=VXFG7lelbxlWZdxPISR9e4Y7xpWUiI8MMy820l1fp4c5+RGcnkR5aASaT+I0CeHbhR G675rlw9G82dInzV/BJ3v4ByUFi24IyCTZmDmcUHEn5jXMz02wyHCye47UVoUY71p0Hq q2PnZ4JYCXyjBPG69yKj43zJmA6WjOQcGbWJW7lsb6Yi6fonfhN3UADBjVxTiG7ZcELr 5d3rupysiU/19IG/O4BfT9i4HOdbG6CywEzoTqJjgPkHfB8cDsNSL/Lvb/rs1Dy0QVdZ hshfook1+FrOorglRQD/mYKCCwPXtosPSjLHOrVo3GWr2MkfzPA1MRzjlq3AHvYjIZGi aS0Q== X-Gm-Message-State: AOAM5324fVRKy6Y3GzRyJZU+B894k5wr23gi5ZAgH0eLWxGKPhmw9emG /4GFtig+gkTfY+aoQKhMf9JCYVQVmUHjYLRZ3UkNuw== X-Received: by 2002:ac8:7dd1:0:b0:2e0:6fe1:189b with SMTP id c17-20020ac87dd1000000b002e06fe1189bmr16058848qte.629.1649420512329; Fri, 08 Apr 2022 05:21:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dmitry Baryshkov Date: Fri, 8 Apr 2022 15:21:42 +0300 Message-ID: Subject: Re: [PATCH v2] drm/msm/mdp5: check the return of kzalloc() To: xkernel.wang@foxmail.com Cc: robdclark@gmail.com, quic_abhinavk@quicinc.com, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Thu, 7 Apr 2022 at 05:33, 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. > > 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 > --- > ChangeLog: > v1->v2 simplify the patch and update the description. > 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 c6b69af..50e8542 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; > -- -- With best wishes Dmitry