From patchwork Mon May 15 15:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9727537 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 AD2DE60380 for ; Mon, 15 May 2017 16:00:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7822289BE for ; Mon, 15 May 2017 16:00:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4894289C0; Mon, 15 May 2017 16:00:07 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 46821289AE for ; Mon, 15 May 2017 16:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934041AbdEOP7y (ORCPT ); Mon, 15 May 2017 11:59:54 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:36850 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932368AbdEOP7v (ORCPT ); Mon, 15 May 2017 11:59:51 -0400 Received: by mail-qt0-f193.google.com with SMTP id j13so16342977qta.3; Mon, 15 May 2017 08:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=OMj29qBckhGvIVMp8PONTX7R/YxmcSoNkYdFS8lQRFk=; b=AjsSMxrxRxy/Q1YrIfEAWz9/pPEh9uNJ3nG0fSOqjenYnlAju9Sco89yZN7s8NbEXQ frf+zokdcp4vVrnolz4BnXlxiiW/zV7OXiUWfH2A0ESNQh2wcaHEHd+/II/adSJyvdtL nad4qbLGsXVc6/thYA+HqJluLpEmmwvZPpCLgY9x5ATeZ5WZtm5RJCx+IAseHSWi6bkP snam2viPl/fGKsJshUHighoUZm5SORQSKR4AiUQ0dFuW4DrK4hGsjfznUkdsJwHOgWqT et4zP9B2mkHW0sywb1H7oUu21h3aKkuR8HVamQaWcxc3RPONJ1aNUkyH9DdY+1MHAzcZ L59Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=OMj29qBckhGvIVMp8PONTX7R/YxmcSoNkYdFS8lQRFk=; b=XpeA11Xw+2tzdM3oWC/7vACTyhOoDeVU6KDVkrV04qj2PKK9WyhNdV3HlMfmmOaSHk e1o+urAIQu04F9vQ7iNUOmbLwSXBogHJ3ZiqjojnQm1ubgtHfsFKE4X3Fzq5VvpoDIzJ ujnQjapVlCjMlhWW4B0eelC3p4Se/4+3OKONFKcPL8c5CVFNkd+IqhM/gSBQIYEt+6Ma h3IG2diNHy2It0wc/tiIAUdcO/B8x5lPzhcrhQuHR7IVUZTOFpqHudZHtWz2zGo7Frcn IL2xhQjCeqPoP3hQ6ESVdEFEw5nl2OXPpNLn3m+W+qm4cIgMUyMk4ixMz8VuE2sXGy5C yvqQ== X-Gm-Message-State: AODbwcACMcWBLTTDb3LQzO3ao3vyKIlHnj8YwUWuTpVQk245KVrFmsm4 1RTdR1JagcKl0A== X-Received: by 10.46.33.212 with SMTP id h81mr2312831lji.62.1494863985385; Mon, 15 May 2017 08:59:45 -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 y67sm2268657lfd.0.2017.05.15.08.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 May 2017 08:59:44 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dAIPQ-0005Tc-4C; Mon, 15 May 2017 17:59:44 +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 Subject: [PATCH] scsi: sun_esp: fix device reference leaks Date: Mon, 15 May 2017 17:59:29 +0200 Message-Id: <20170515155929.21014-1-johan@kernel.org> X-Mailer: git-send-email 2.13.0 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 --- 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; }