From patchwork Mon Nov 6 23:37:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 10044765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B19560247 for ; Mon, 6 Nov 2017 23:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0BEE29D3D for ; Mon, 6 Nov 2017 23:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E53BB29E22; Mon, 6 Nov 2017 23:37:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F31B29D3D for ; Mon, 6 Nov 2017 23:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752673AbdKFXhP (ORCPT ); Mon, 6 Nov 2017 18:37:15 -0500 Received: from www.llwyncelyn.cymru ([82.70.14.225]:48110 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751954AbdKFXhO (ORCPT ); Mon, 6 Nov 2017 18:37:14 -0500 Received: from [10.40.0.25] (82-70-14-226.dsl.in-addr.zen.co.uk [82.70.14.226]) by fuzix.org (8.15.2/8.15.2) with ESMTP id vA6Nb9AS018617; Mon, 6 Nov 2017 23:37:09 GMT Subject: [PATCH 3/3] atomisp: hmm gives a bogus warning on unload From: Alan To: vincent.hervieux@gmail.com, sakari.ailus@linux.intel.com, linux-media@vger.kernel.org Date: Mon, 06 Nov 2017 23:37:09 +0000 Message-ID: <151001141201.77201.10725942741811192730.stgit@alans-desktop> In-Reply-To: <151001137594.77201.4306351721772580664.stgit@alans-desktop> References: <151001137594.77201.4306351721772580664.stgit@alans-desktop> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The problem is that we allocated a dummy page to ensure that 0 aka NULL isn't returned as an ISP pointer into the hmm space. The free routine rather sensibly checks for bogus NULL frees but is tripped by hmm_cleanup freeing the dummy. Split the routine so that we can keep the protection check and avoid the bogus warning on a cleanup Signed-off-by: Alan Cox --- .../staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index a1c81c12718c..dfb9bf54b5d2 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -42,6 +42,8 @@ static ia_css_ptr dummy_ptr; static bool hmm_initialized; struct _hmm_mem_stat hmm_mem_stat; +static void hmm_do_free(ia_css_ptr virt); + /* * p: private * s: shared @@ -211,7 +213,7 @@ void hmm_cleanup(void) sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group); /* free dummy memory first */ - hmm_free(dummy_ptr); + hmm_do_free(dummy_ptr); dummy_ptr = 0; hmm_bo_device_exit(&bo_device); @@ -268,13 +270,10 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, return 0; } -void hmm_free(ia_css_ptr virt) +static void hmm_do_free(ia_css_ptr virt) { - struct hmm_buffer_object *bo; - - WARN_ON(!virt); - - bo = hmm_bo_device_search_start(&bo_device, (unsigned int)virt); + struct hmm_buffer_object *bo = + hmm_bo_device_search_start(&bo_device, (unsigned int)virt); if (!bo) { dev_err(atomisp_dev, @@ -290,6 +289,14 @@ void hmm_free(ia_css_ptr virt) hmm_bo_unref(bo); } + +void hmm_free(ia_css_ptr virt) +{ + WARN_ON(!virt); + + hmm_do_free(virt); +} + static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr) { if (!bo) {