Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp247429iog; Wed, 15 Jun 2022 01:14:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd8IWqYMDsZftJ9weRgqfksUjYUHcYIGQMN7zrKUDaXWXfi5MJhxOXMDZZqP/OY91RbPsH X-Received: by 2002:a63:89c1:0:b0:3fc:5fd2:54e4 with SMTP id v184-20020a6389c1000000b003fc5fd254e4mr8024331pgd.344.1655280895521; Wed, 15 Jun 2022 01:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655280895; cv=none; d=google.com; s=arc-20160816; b=qUipo7V0ePki+hOJZ28z2FhlSk9kWZC4xMtJt4enp3pIjLcNxbF7/235U5OgrBqW/R lqRcjxuS3zgPWSC893TdHWS1m1Qbo4MN4GDU9WF1NnIAGbYCWlxqijVQXQqYZpA8fXFf 4ps/C7qOdD/PO9xHcUtvdcPsYugmm620IaxyPrwtputUVUEen0jHZE9VdOsDdGcxTlKT /9Xv0IvSV+xFDp50HmEJkT3vDB7iwkiQ9NDvrANj2V3g+P0CL7B0iM4MHMOS29C8ejv9 W+Sb8RkZvirCm07LzI8B3RrT/M70IAEazy5APenh6HJlH1k54kHLFcqmaYHsxOmO0RGO rEFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=KxJwb7e41sD9SUwoENJ/KJ6jHIXqxYl90TOkETI/KCg=; b=D5yqZDgGKAHdNRZG9TFMHsXjwQvdGA5HU7Hp9AyfJ7ejqVir8048v/dMoY5vJt3QGF 2NPmSI2mdtAw+8l1wsGVMHYrIFASKCSp0n4Vl4vu3Wfh1l4OTQAFx2Qx/opaWlYvhuqW 5OtAeQU22N0hXACBcOSYvLJiIcfEV5DZTr4tve6TZbaCC5AVViyCrS0WfxTdFYMmMCFW YKz2J+mInWvgAgoG12VXBhcFgjpI6eGt4kz6I8k/UOnqvvpxV8hacCOSWhJi+/xvctKT nzkkjH341PBxvHh7rXXjRnc9Hh8t8ibWEKvsfeTtiUDFmzEHrtaglZmDM7udNFGgPQDf w8gg== 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 lr2-20020a17090b4b8200b001c6a62efe0dsi1801263pjb.89.2022.06.15.01.14.42; Wed, 15 Jun 2022 01:14:55 -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; 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 S245500AbiFOHyU (ORCPT + 99 others); Wed, 15 Jun 2022 03:54:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234338AbiFOHyM (ORCPT ); Wed, 15 Jun 2022 03:54:12 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4481427F8 for ; Wed, 15 Jun 2022 00:54:11 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 12E6E1E80D27; Wed, 15 Jun 2022 15:52:43 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V5N6kuqPlSIw; Wed, 15 Jun 2022 15:52:40 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id A37F11E80CFF; Wed, 15 Jun 2022 15:52:39 +0800 (CST) From: Li Qiong To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, yuzhe@nfschina.com, renyu@nfschina.com, Li Qiong Subject: [PATCH] drm: check for allocation failure of kstrdup_const() Date: Wed, 15 Jun 2022 15:53:09 +0800 Message-Id: <20220615075309.18955-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_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 As the possible failure of the kstrdup_const(), it should be better to check it and handle it. Signed-off-by: Li Qiong --- drivers/gpu/drm/drm_managed.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c index 4cf214de50c4..d9bd4a9da559 100644 --- a/drivers/gpu/drm/drm_managed.c +++ b/drivers/gpu/drm/drm_managed.c @@ -151,6 +151,8 @@ int __drmm_add_action(struct drm_device *dev, } dr->node.name = kstrdup_const(name, GFP_KERNEL); + if (!dr->node.name) + return -ENOMEM; if (data) { void_ptr = (void **)&dr->data; *void_ptr = data; @@ -197,6 +199,8 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) return NULL; } dr->node.name = kstrdup_const("kmalloc", GFP_KERNEL); + if (!dr->node.name) + return NULL; add_dr(dev, dr); -- 2.25.1