Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3867494pxv; Mon, 19 Jul 2021 10:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDrCxCtZYh7g6hkqSCrXPh9IESnLgWmXDC4HaBylTwoy7mFlbFoSZa7vc/3rPKD85JL9Lu X-Received: by 2002:a50:fe8d:: with SMTP id d13mr36007939edt.14.1626716349899; Mon, 19 Jul 2021 10:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626716349; cv=none; d=google.com; s=arc-20160816; b=vqLFcBlvZmMetOxeUI85D83aLbw44689tyWEExQqtPvKJzIVAGbHyt1QwwwffPm4y9 zr4Ba6mRJhAbcKj8VttJalKAfzrR56nLuUTr7TEgGHrXUe9uKTUPkSKzrvGZWwKL33ye Qm5d13oPp+RC7a0i/CUFi0UhLdTlgN5heLowPTZQc2n8VmPMnw3Gy0fmfC4BPyLChEkB /iBmLTdIGyRywxCBtVeWUgdWGVX0blP/8Ap4nFzd/Cq91Eob+V3oPH3L/fgK0nVZCPFM aRoi/g/51wRj4+vJZ8RR/j++m67S64QzclMgsIOTq6qMxFpvGXObHFV9yUrcXV9wL/tb kI6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X3kbtJHYmNX7iPZlNyC28n9UyNMDMb6tMhwevAUjrRM=; b=nD3JEtmAgg8NH3Nj0KzuattXHSnIgBHDJE9GUaXYPEq6vj6tQaOwyn8tRulPDwdvCw 74OwkfVrLFkPoJh7epN21eVBrcWhMU/1UTyrterMLnC4opUHPNbekjY3CS0C2OBMO0OH C10kcWa76dzI7aaxIi3BeqpgBxiKhGxDtLkNPDdK2B5+H/LVHQI4RktGwdgcj7U6crbE VgCP813RR4bNaCgNrz06ojW2cPpWEDXwjvydPoK9aqW2KHMe4YVQm15T5TwcZYryics3 lMoD/valRRZpbU9pDRou13mqGxzeSrZB9AyzA0pqf/8g4zoREaxHkBaSvJitvOdyEN4o ezpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wQAR26V/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si27598928ejy.271.2021.07.19.10.38.46; Mon, 19 Jul 2021 10:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wQAR26V/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357339AbhGSQvc (ORCPT + 99 others); Mon, 19 Jul 2021 12:51:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348017AbhGSPYR (ORCPT ); Mon, 19 Jul 2021 11:24:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDBCE611C1; Mon, 19 Jul 2021 16:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710433; bh=rwzGqL9E430fV40mb9qcXcGWbH17WOZWxI28qKfql3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wQAR26V/wcKAC8j2sWfO6ZVSsz8kRs6H1pylzhY47m+DsHb0yHb/Xe3gPxvyNWdgz tkjMU9vVSd+SAO2j21Y/iH37FYadoJt6Y1j+dMFHWZuo23ac18rzuEyPkTDJHR/qc+ +qi0/4zp97NUuekGfhwfnwkWztYA2dCPGN40EvHc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Philipp Zabel , Sasha Levin Subject: [PATCH 5.10 213/243] reset: bail if try_module_get() fails Date: Mon, 19 Jul 2021 16:54:02 +0200 Message-Id: <20210719144947.799401343@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Philipp Zabel [ Upstream commit 4fb26fb83f0def3d39c14e268bcd4003aae8fade ] Abort instead of returning a new reset control for a reset controller device that is going to have its module unloaded. Reported-by: Uwe Kleine-König Fixes: 61fc41317666 ("reset: Add reset controller API") Acked-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20210607082615.15160-1-p.zabel@pengutronix.de Signed-off-by: Philipp Zabel Signed-off-by: Sasha Levin --- drivers/reset/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index a2df88e90011..f93388b9a4a1 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -567,7 +567,10 @@ static struct reset_control *__reset_control_get_internal( if (!rstc) return ERR_PTR(-ENOMEM); - try_module_get(rcdev->owner); + if (!try_module_get(rcdev->owner)) { + kfree(rstc); + return ERR_PTR(-ENODEV); + } rstc->rcdev = rcdev; list_add(&rstc->list, &rcdev->reset_control_head); -- 2.30.2