Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp854722pxk; Thu, 17 Sep 2020 19:11:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN20cs/bdJ7IY/Lc65dl9Iiko62uYxpmuwB637LOHuUPdE3rOUI/SktgOhYyUyLNG2wtyj X-Received: by 2002:a17:906:2985:: with SMTP id x5mr33093151eje.136.1600395090165; Thu, 17 Sep 2020 19:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395090; cv=none; d=google.com; s=arc-20160816; b=kjf3uNu6Pbk+4REDIv89NdkHlszOhkfywBh2+5mJejxvu4G4KlDuCbcJwWAqbj1DN0 DkSIfO7skdpdX8910bKjKL5ve3d2wTQGrnq+HLRnB9HcAC+xuvOQFCYNhz79myJOwCqb kvMX2whkmILpEhbiWZPskeUQuoqrh1Yek1hgMt9T4Iyx/zpKa6llO3hVRf97hDT8KAe9 6DrBda2KytwFlqAFbQ59XR/9rec8SGTbhQhhQHYzCcF7IySDcms9kKTUx7gowH6oax3K /6Zrl50kkF8vS5GbR9oJNxctFc6+uCyCfwd6aNN0tSsUb3XO6k29l6q+9JQeO4329f9+ iIcQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ATmUoMvwkBllSmJPVz9nsW5g8Z254nX570LEoOtDpM0=; b=oQJ9v3zGFfw8VrRaVDc1nk9/Ly+Ej9P8XphLuRZKqrkakZx+vVlTWo8/c/IjADl1Yv 1Bv6BdjdaivTp8rrkCYouiNlSjd1sS2ywXwaCmArltzjdC8Y57saGuLtXhXNcfu81X+q gYTYC7OxA8xC04nuxOfieZEnzTy4MdlYUiClEVkNbtPDzYCsJLnoZQCU+qHmXTrhf59U I2IZHUIzBy7tkLOUYQrGFLb78d9uDY7pN4DM0HyTh241pu+jPacfWFzCTv6ea6Ph1iaF fzSjhv58PtFmkV2PqXsvRS9YNKyCEZ/37rAVIgdCs6FosJJ08XLUY5+LZ4P3qfrCXyuc 3GJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rngAtvDb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v15si1103240ede.489.2020.09.17.19.11.06; Thu, 17 Sep 2020 19:11:30 -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=@kernel.org header.s=default header.b=rngAtvDb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726729AbgIRCHJ (ORCPT + 99 others); Thu, 17 Sep 2020 22:07:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgIRCGk (ORCPT ); Thu, 17 Sep 2020 22:06:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95DF82388E; Fri, 18 Sep 2020 02:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394800; bh=4QEX68LXmMj1dBXpx9bC+bzvAKqkEWyUNcAaYFv82EY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rngAtvDbZ3YWBYPbNN6wKKpAzCEspLDrzVKw3Vgju7fBJS9xHdAPpini/fbGaLG+u JPu46DjCzNDFUZrYxrJFwVe+Hxz+AhGx6arMubhDzg6b3VugWTQnEte+DwGqXKlo5S IYFkySsFNGoPMHfTP1wjeDDqhix0uq+3s0yNG3E0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tang Bin , Shengju Zhang , Corey Minyard , Sasha Levin , openipmi-developer@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.4 269/330] ipmi:bt-bmc: Fix error handling and status check Date: Thu, 17 Sep 2020 22:00:09 -0400 Message-Id: <20200918020110.2063155-269-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tang Bin [ Upstream commit 49826937e7c7917140515aaf10c17bedcc4acaad ] If the function platform_get_irq() failed, the negative value returned will not be detected here. So fix error handling in bt_bmc_config_irq(). And in the function bt_bmc_probe(), when get irq failed, it will print error message. So use platform_get_irq_optional() to simplify code. Finally in the function bt_bmc_remove() should make the right status check if get irq failed. Signed-off-by: Shengju Zhang Signed-off-by: Tang Bin Message-Id: <20200505102906.17196-1-tangbin@cmss.chinamobile.com> [Also set bt_bmc->irq to a negative value if devm_request_irq() fails.] Signed-off-by: Corey Minyard Signed-off-by: Sasha Levin --- drivers/char/ipmi/bt-bmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c index 40b9927c072c9..89a8faa9b6cfa 100644 --- a/drivers/char/ipmi/bt-bmc.c +++ b/drivers/char/ipmi/bt-bmc.c @@ -399,15 +399,15 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc, struct device *dev = &pdev->dev; int rc; - bt_bmc->irq = platform_get_irq(pdev, 0); - if (!bt_bmc->irq) - return -ENODEV; + bt_bmc->irq = platform_get_irq_optional(pdev, 0); + if (bt_bmc->irq < 0) + return bt_bmc->irq; rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED, DEVICE_NAME, bt_bmc); if (rc < 0) { dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq); - bt_bmc->irq = 0; + bt_bmc->irq = rc; return rc; } @@ -479,7 +479,7 @@ static int bt_bmc_probe(struct platform_device *pdev) bt_bmc_config_irq(bt_bmc, pdev); - if (bt_bmc->irq) { + if (bt_bmc->irq >= 0) { dev_info(dev, "Using IRQ %d\n", bt_bmc->irq); } else { dev_info(dev, "No IRQ; using timer\n"); @@ -505,7 +505,7 @@ static int bt_bmc_remove(struct platform_device *pdev) struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev); misc_deregister(&bt_bmc->miscdev); - if (!bt_bmc->irq) + if (bt_bmc->irq < 0) del_timer_sync(&bt_bmc->poll_timer); return 0; } -- 2.25.1