Received: by 10.223.185.116 with SMTP id b49csp2153867wrg; Mon, 12 Feb 2018 05:20:28 -0800 (PST) X-Google-Smtp-Source: AH8x224mAWFV5+a7qU839jQvZzMkJn4MPYL/6tWcGn3hiQ21tHTO6BlHIFe7g58TFXcUVhp8H+/X X-Received: by 10.101.72.75 with SMTP id i11mr9024674pgs.78.1518441628877; Mon, 12 Feb 2018 05:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441628; cv=none; d=google.com; s=arc-20160816; b=0OXtptIOpU2GAXASXu0UW3jaaP+pXPGTYPi5YhtYupClCmECTFA8Y1ncVIyJfE7INu MxylIOYcpkuXQ+CuzhNpVRibsOUMgjQ9YZlVUGA+tbBZbUrFLgNzsy4xLZjvQQf0yYMq WFpjZnN56CaweO97Fv8VHBxfQHyfao/SFA+/9+897C3cUMZywy7u1ux6t8mFH5wG4j/w k1QS53AzRlYY/1IHIwsjj3+42OzZI/bVuDkjTTdQVUPmFEjCjzP4kNIeNYTE3yQIs+PC TRS2REQD5RC+vECCkt2Tfh2CPUH2d/DBoi8yu9K1/BFAXn8lbRaU1aBFi3hktyGUtSys JXJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=+t2CuJIlZfhSKhOy5v8UYHX7+NFKt6BofeTR+SCaeSI=; b=A8gK4c0ANgdLegMS8ufiR359wOYilUHWDse2AQxQ9epgvMrZ0r9146j63N8S7McnKL SuO2TsicuN/+xw1wIZzs12dxZMk6aDs+UXJyuWhwg61kendCrZrU9ubZXPpKsToob5Hv Na6aVqx4eVD6wMUoxG5QHM4HeorXLYhlKYv0J6/D85BifvzXMB29eUjkDGIe2wtDR7/F WGWu5vYBZwPo2d/oIKY5TjnaImu5V5X46Zre6y4sKZqFxLnXqc1CJvokNp1KavxwEu9/ U3y8R2UATr07cl97/Mw6k+MwFcsJwxsvkMsa/HV55otaQ+AiE081bFBH4i3OWUM/FJm1 T53w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si1820317pgf.93.2018.02.12.05.20.14; Mon, 12 Feb 2018 05:20:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933855AbeBLKxD (ORCPT + 99 others); Mon, 12 Feb 2018 05:53:03 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:5201 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754089AbeBLKwh (ORCPT ); Mon, 12 Feb 2018 05:52:37 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7F8C2E4C152DC; Mon, 12 Feb 2018 18:52:24 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Mon, 12 Feb 2018 18:52:15 +0800 From: Yisheng Xie To: , , CC: , , Yisheng Xie Subject: [PATCH v2 4/9] staging: android: ion: Avoid NULL point in error path Date: Mon, 12 Feb 2018 18:43:09 +0800 Message-ID: <1518432194-41536-5-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1518432194-41536-1-git-send-email-xieyisheng1@huawei.com> References: <1518432194-41536-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we failed to create debugfs for ion at ion_device_create, the debug_root of ion_device will be NULL, and then when try to create debug file for shrinker of heap it will be create on the top of debugfs. If we also failed to create this the debug file, it call dentry_path to found the path of debug_root, then a NULL point will occur. Fix this by avoiding call dentry_path, but show the debug name only when failed to create debug file for shrinker. Acked-by: Laura Abbott Signed-off-by: Yisheng Xie --- drivers/staging/android/ion/ion.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 57e0d80..4b69372 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -564,13 +564,9 @@ void ion_device_add_heap(struct ion_heap *heap) debug_file = debugfs_create_file(debug_name, 0644, dev->debug_root, heap, &debug_shrink_fops); - if (!debug_file) { - char buf[256], *path; - - path = dentry_path(dev->debug_root, buf, 256); - pr_err("Failed to create heap shrinker debugfs at %s/%s\n", - path, debug_name); - } + if (!debug_file) + pr_err("Failed to create ion heap shrinker debugfs at %s\n", + debug_name); } dev->heap_cnt++; -- 1.7.12.4