Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp443326iog; Mon, 13 Jun 2022 06:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW9rPE+73Dg4oa/Az4LkCrFeYzsyZ3dtdPUoyf5wEoVQP2YPR1GMHnYI/u+VNXlUV5rrMR X-Received: by 2002:a05:6402:84c:b0:430:aae2:6dd8 with SMTP id b12-20020a056402084c00b00430aae26dd8mr52392370edz.31.1655125596742; Mon, 13 Jun 2022 06:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125596; cv=none; d=google.com; s=arc-20160816; b=f8GJT3sEtBK70JyqEDjhvXa2oGyHLL7k9ZU6my5Q4zF6zOD/GLm74YLJwMTYskv2v1 yI7rjIKnOPA3hYAWSdg9GJuwZtdJTFem0OTdrUolM2dfAMqUTQ56XjwRRSm+1coXey+R HfBgmJMAW1M8z+Sa0YCeE+TJwxah0MqEVOjnq2MtAs1e0zuebsr6pwc195rWU9D0/pXO 1ZMjmdt3esYpsEhTys0jzFWIJ3EhbxYNNn+l/6L1d6mhPJW4BOpppFbzpZ3U609NuGmh EigSNOZxk+l8HeXRGxynNAvbqWDU6KnscJnAf2FmAzYS0RGJn+6YtQE3ah9StOZ7RSsI M3JA== 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=shqFzE1EzOvqYLR1A0BYO89UpFiqJ+0LYCNe49tE09A=; b=f5q45fjiSD2g0Iuj1DwGTPhenSSc2cJaFZitadWEiS8SHUQIRhd6WwFLJYI42VEII9 fw16cUElb1TpFsWMoXlBUSjWNTCD2LRxtvK0kpGb/9U/V1OP3jY6VDF197l/qY44EiYA JmSqyQE/8HHLc1qq7or9lOZMhHUzN23JkjMv4/iHjsCmO22TkQGVwoNrj2YPGSlLGVeP jWAX4/zOLZgGHIq3yPwJi913oZBzfM9OBUn/kBSiOK/r7yiOW3IvdiyCMdYX5qzJHzrg 6hBXl+wMdmrl/AOb0UDZWUMw9pDKav6b/ch/s79bHhzqWwf86fe7DBnBOuKw/7np9OB0 454g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m8IYnK8L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw8-20020a170906478800b007174e91f206si4460165ejc.217.2022.06.13.06.06.09; Mon, 13 Jun 2022 06:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m8IYnK8L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1351746AbiFMLKC (ORCPT + 99 others); Mon, 13 Jun 2022 07:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351872AbiFMLFL (ORCPT ); Mon, 13 Jun 2022 07:05:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88A2F27FD7; Mon, 13 Jun 2022 03:34:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24F3160EF5; Mon, 13 Jun 2022 10:34:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 345FDC34114; Mon, 13 Jun 2022 10:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116464; bh=vYzLSmQkbnTtiS//7dQpP11ufnfqxIvecp/s4C8a2C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8IYnK8LlRkAS4fv3F/7CuzzVzsk0xFvaE9lZOdnbZVXwXIMzIwrAjFzMqF6+Ti4X CIGYCqryTC2Gka7n6Cza9M9BpoCeIxMemecmcE3QilqlPDGfoxDwaXijmsPis3dtDt kfTpmtAWrdXD3S1ZHvtL9GS/O6D13aHXJHdbj6Ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhen Ni , Sasha Levin Subject: [PATCH 4.14 186/218] USB: host: isp116x: check return value after calling platform_get_resource() Date: Mon, 13 Jun 2022 12:10:44 +0200 Message-Id: <20220613094926.254631404@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhen Ni [ Upstream commit 134a3408c2d3f7e23eb0e4556e0a2d9f36c2614e ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Zhen Ni Link: https://lore.kernel.org/r/20220302033716.31272-1-nizhen@uniontech.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/isp116x-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 73fec38754f9..83eb62001679 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1551,10 +1551,12 @@ static int isp116x_remove(struct platform_device *pdev) iounmap(isp116x->data_reg); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - release_mem_region(res->start, 2); + if (res) + release_mem_region(res->start, 2); iounmap(isp116x->addr_reg); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, 2); + if (res) + release_mem_region(res->start, 2); usb_put_hcd(hcd); return 0; -- 2.35.1