Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp48954imu; Thu, 8 Nov 2018 14:33:26 -0800 (PST) X-Google-Smtp-Source: AJdET5coYAFgvJhUzobjN+1XuEvFApsQ78G75DdGLjbOzZwN8qe0y6T+hkeKes8WWgm51D08r9zS X-Received: by 2002:a17:902:e005:: with SMTP id ca5-v6mr6248818plb.195.1541716406293; Thu, 08 Nov 2018 14:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716406; cv=none; d=google.com; s=arc-20160816; b=xmJTYTCQzj4dJQZyt3gbe2YVXpDAp7Btq7G9zQsIxsDkitwEcLHjTdMVuPoJxcoqSN BUApafDQ0nVhDqh1QCfDbVtlouzvLjxg1H0gF701LRlnyuFXAGngof8+Kmjibno3/F0A iD54bXcSd3ViYBwcUefd+5Yf1m5MjgaDXXF0uFbzOcSMRpwJM8yA56OfEMk/bMEo1Flo DWotD4lDtwi01/p+0jPP+S7Nk9tnvezJF1cAD9NvsNPAvcNwW1l4vGjiBpuOdcmh3PgZ GQFcZrIyPhXdqax4bu1WtqXeplKAA3hpoA3L1QAE+tprBZljucpUHD6vmN3yeMYd7QjZ V9dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2dNa6TC9BJYWA/ZsBwCch+YhNVcXu7/sEIQgxcfuDz0=; b=lPagmkQRvwtwRqYfYcy/DNhbPb7tgBmwDfCPIcx40llDQVYcdMnHyNgCvWN8wwTl5P MQXfNt3qPU3qHg8nLrNAP5Rosr9nIkduhmvOgf+bBn8T7fXkH2uk2AQuquVhHJ40os05 1kZerpzhURJtuOQhKsulLdG5WjEPtlOKX0UmJPbfBfRreWwFhyZPmMG2JCkXLyo8AI35 9opgAC0qkGxxy9I8xmi1t1bAQ9GbU73SHsqRwBUKW8OQoUm+2UptZ45sakm4Su5MNpzM bRPQ2GML3K7h1zu8wvM8zP9P8Wrg+Z6CfrEp0TtBXMdoPI0fzXXaIR+n9pgrnXxZr1H9 4prQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qZ63gcFG; 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 o12-v6si5849280pfh.9.2018.11.08.14.33.11; Thu, 08 Nov 2018 14:33:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qZ63gcFG; 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 S1730482AbeKIHhz (ORCPT + 99 others); Fri, 9 Nov 2018 02:37:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:56674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729254AbeKIHhy (ORCPT ); Fri, 9 Nov 2018 02:37:54 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1663E208E3; Thu, 8 Nov 2018 22:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714426; bh=HMnt/gwabkufMXC2+3GiYTf8vI681mW6XWvYtLHvoSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZ63gcFGceUqHvrjkO6d/Tupxeqwoe7rTd4XaQ811siuYJxrUqMs+m+HoypQe5WGp VUtYvu8JqvOqD5hJjTvlha707m7pzpHb40tMGQVW2eDy/kybr0ZDEwDL8vkljFKtAL VWW0en2QanPsHuMPNOIhsh3dGgH1+cKQ8BBu9K7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jarkko Sakkinen , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.4 036/114] tpm: fix: return rc when devm_add_action() fails Date: Thu, 8 Nov 2018 13:50:51 -0800 Message-Id: <20181108215104.226618623@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 4f3b193dee4423d8c89c9a3e8e05f9197ea459a4 ] Call put_device() and return error code if devm_add_action() fails. Signed-off-by: Jarkko Sakkinen Reported-by: Jason Gunthorpe Fixes: 8e0ee3c9faed ("tpm: fix the cleanup of struct tpm_chip") Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm-chip.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index e759100e41a7..28894878dcd5 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -230,7 +230,11 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, chip->cdev.owner = dev->driver->owner; chip->cdev.kobj.parent = &chip->dev.kobj; - devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); + rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); + if (rc) { + put_device(&chip->dev); + return ERR_PTR(rc); + } return chip; } -- 2.17.1