From patchwork Wed Jun 21 09:35:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9801329 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 F0A1860329 for ; Wed, 21 Jun 2017 09:35:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF3D81FF12 for ; Wed, 21 Jun 2017 09:35:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D36C2262AE; Wed, 21 Jun 2017 09:35:31 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 9402E1FF12 for ; Wed, 21 Jun 2017 09:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbdFUJfQ (ORCPT ); Wed, 21 Jun 2017 05:35:16 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34507 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbdFUJfO (ORCPT ); Wed, 21 Jun 2017 05:35:14 -0400 Received: by mail-lf0-f65.google.com with SMTP id l200so8172912lfg.1; Wed, 21 Jun 2017 02:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:sender:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=XxDIwa+t6gZRiAmN6jgXc8/aXIPWHCpCgOCsVl0tZHg=; b=eF7CnBwi44VWxbLHkGF4FqbZkg6/1tKPY0eeZFxPqmZgsROk63/FlCcsdZ0BDZscVM m1jj8EYCeSzmHSZNAoPgw+Znq+oSEyDqFU+UzX4EBWlUU0ho+OQLBuJcUyE851K8nzb5 PxdOn3n5htwD11VqLQhVwRXF2KGu7T2ZyYG7kqmVWtDBDiob9u6lBLvOwztWBH+4T23H /CDnA9Erj0o0glhEQK256XsHLZ3Dx1VVGTOQJsXX++nHVOy0Mj9Sud7czvEtJb5Qv3VQ GKx9kIqdBIQ6ICREWuJrHBLRoIaxFuBBXI8OYGznkYhejIx64vGNp8y/4X2nFVm1ycah hpug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:sender:to:cc:subject:message-id :mime-version:content-disposition:user-agent; bh=XxDIwa+t6gZRiAmN6jgXc8/aXIPWHCpCgOCsVl0tZHg=; b=K1SZ9VJz0BoqbUXhtYGIMH2n8O/2ewWyn+j2nEuqR4HOTAYpUU8QoEMzUx9iGhVnGe 98yqTlfStsBUUVQD4uIxlvHqtPlygZeSuLSkyx7IRFWwAjFvZBF8WfZrYyt9soi5h6/h pD+eaz5h4npG0oFPziyekm4xoIOYcNh4PpdkUtXEUed8gTuMBO+Hnwfp576riPwW1RiK 1+lNgRi4zxbJzWAZ3mCGM0fL652JjZjvnEy+PblTEGNGkN6dEfMbhMNH9qjiChtm6l72 lEV5pNAAeB2Cb0Ne80NHXrIeDlQL61ZOyVafGfJYlpcsDLQ4oVfMuBD7jOIwiCh3VFFB KIyw== X-Gm-Message-State: AKS2vOzAeAHefFpmY36WqEmOIE/3dVbUiUpqtwZxaCN5u65/VQc6s8f1 es54SWi4iGAm9g== X-Received: by 10.25.15.221 with SMTP id 90mr754507lfp.10.1498037712659; Wed, 21 Jun 2017 02:35:12 -0700 (PDT) Received: from xi.terra (c-42c8e255.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.226.200.66]) by smtp.gmail.com with ESMTPSA id i127sm4642661lfg.40.2017.06.21.02.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 02:35:11 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dNc2X-0001U8-2e; Wed, 21 Jun 2017 11:35:09 +0200 Date: Wed, 21 Jun 2017 11:35:09 +0200 From: Johan Hovold To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , "David S. Miller" Subject: [PATCH RESEND] scsi: sun_esp: fix device reference leaks Message-ID: <20170621093509.GL6366@localhost> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to drop the reference to the dma device taken by of_find_device_by_node() on probe errors and on driver unbind. Fixes: 334ae614772b ("sparc: Kill SBUS DVMA layer.") Signed-off-by: Johan Hovold --- No comment to this one for over a month so resending. Also added David Miller on CC. Johan drivers/scsi/sun_esp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c index 7b6d4c2087d7..747ee64a78e1 100644 --- a/drivers/scsi/sun_esp.c +++ b/drivers/scsi/sun_esp.c @@ -566,6 +566,7 @@ static int esp_sbus_probe(struct platform_device *op) struct device_node *dp = op->dev.of_node; struct platform_device *dma_of = NULL; int hme = 0; + int ret; if (dp->parent && (!strcmp(dp->parent->name, "espdma") || @@ -580,7 +581,11 @@ static int esp_sbus_probe(struct platform_device *op) if (!dma_of) return -ENODEV; - return esp_sbus_probe_one(op, dma_of, hme); + ret = esp_sbus_probe_one(op, dma_of, hme); + if (ret) + put_device(&dma_of->dev); + + return ret; } static int esp_sbus_remove(struct platform_device *op) @@ -613,6 +618,8 @@ static int esp_sbus_remove(struct platform_device *op) dev_set_drvdata(&op->dev, NULL); + put_device(&dma_of->dev); + return 0; }