Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp58540iof; Sun, 5 Jun 2022 21:03:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw81rbK8r58Zn6wacDOYS3orNjC78jCrTnYfjDocYWcUbDFt7NCiw90i+3YgT2MvupmDEc9 X-Received: by 2002:a17:90a:cf0f:b0:1e2:e62b:fd3 with SMTP id h15-20020a17090acf0f00b001e2e62b0fd3mr24712866pju.107.1654488193330; Sun, 05 Jun 2022 21:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654488193; cv=none; d=google.com; s=arc-20160816; b=UZF2diHleDcCT9Mh7x7PV9CPoJ1EfsLOHpd79ZovsgxOw1yWsE04IPktGXCtF9nS99 6HrZz5nYoPHQSE0BjS9pbJMLOFW6/i7BxX0uIiho0bSGIqJshozEP0mEmHGEGv1D5peJ xq7+RA7Ap07AQak5b3GLdHH0Qumltw9pE1VmZYoGyM8gF+nmlErOxAf++6tS5BZ2zXbR 4a+93vcBjsirtwf4bfDyNfsmwD8lxeow34XVO2MB9W45dw3aE8yoE1EAtROUvsh5eqx5 0HXvQ16lEWodYZWHcIR4/7a9w9od+Vl+vO+90dXuJQpe8pEk8GPF0jBd0A5F9xg96JOC geiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=6blk1zWjTfRbXW7KJFjVY/jp2csjnWRYFdcTz82ZD7I=; b=RYfzy4UKc/N0mhM5ujTXPSApYSLuW5mW2sjSOC8LAhebhE7INfy8fyoL9LIerrmdeP jp7z19+4Tqv/xtoWiKzy4tNeeSPsRN2AhgqB/JT7URQ3tqZaXS57eIapi/Kx50ml6l+/ KxPLYERPMtVddlypcr0eabcjxdkzqkNYWG4yWOAgCmmp1OM8T2RJc6WAw5HV86Ei0ZgM e5dd8qT4aFxJMbznPNJ3Fl7aUK02zk7uMD07/AKSbSO6BU/vawTJBKCPFaHYNTtZTHDP pUwejSLMXDsOa5Cq2Ct//wVerCDqPgP6AZm42gxt/+uO2sTN3AEr1C5vc9f+fAIZFVGj /j6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id on8-20020a17090b1d0800b001df8cee9818si20568935pjb.173.2022.06.05.21.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1ECC86A057; Sun, 5 Jun 2022 20:47:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243558AbiFENb5 (ORCPT + 99 others); Sun, 5 Jun 2022 09:31:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiFENby (ORCPT ); Sun, 5 Jun 2022 09:31:54 -0400 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8C0935846; Sun, 5 Jun 2022 06:31:52 -0700 (PDT) Received: by mail-qk1-f171.google.com with SMTP id x75so5868106qkb.12; Sun, 05 Jun 2022 06:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6blk1zWjTfRbXW7KJFjVY/jp2csjnWRYFdcTz82ZD7I=; b=6QyxyWhCzgYo3Z/WlrPnxxq2EAvOzvncD6jY0c4atO8NRmnBOcfcU2ZK+2b/i+65kv 2qjeC9uXMoGaI0rI+hfe9QkJqd2L2qKy5HUCyd3fyMXbN5Dktjhn9V7FnDptRqg7YDZE /39idy8zDvZOG+vibVzITCozfixk8KWLL10Ms3mrkO6Le4FWTeXCpKRJv1fAP5sAcJi7 pn2ZoXrh185m6zMLllEwCatgB9DfItJSu3CbWQxApwRledqLqhUKpMGcnvgqcUmG0VGQ FcIM0AxUJ7plviOjRPVQFtZrqjA+aZr+ZMML8WjAczre180Yl0qsCXisFMFc9waG6oX3 i4IQ== X-Gm-Message-State: AOAM530f/WLLcAWKFG26KIBax1+Eq0ATHSBODed4kn/nc/GIyUNP5XKc oR21Mv4vXb3IwCS4JDx09mX63E1ff8xZBQ== X-Received: by 2002:a05:620a:142f:b0:6a6:b667:49e0 with SMTP id k15-20020a05620a142f00b006a6b66749e0mr1362358qkj.167.1654435911580; Sun, 05 Jun 2022 06:31:51 -0700 (PDT) Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com. [209.85.219.177]) by smtp.gmail.com with ESMTPSA id s18-20020a05620a29d200b006a6a904c0a5sm4045329qkp.107.2022.06.05.06.31.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Jun 2022 06:31:51 -0700 (PDT) Received: by mail-yb1-f177.google.com with SMTP id r82so21432567ybc.13; Sun, 05 Jun 2022 06:31:50 -0700 (PDT) X-Received: by 2002:a05:6902:a:b0:65c:b38e:6d9f with SMTP id l10-20020a056902000a00b0065cb38e6d9fmr20826776ybh.36.1654435910661; Sun, 05 Jun 2022 06:31:50 -0700 (PDT) MIME-Version: 1.0 References: <20220302033716.31272-1-nizhen@uniontech.com> In-Reply-To: <20220302033716.31272-1-nizhen@uniontech.com> From: Geert Uytterhoeven Date: Sun, 5 Jun 2022 15:31:39 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] USB: host: isp116x: check return value after calling platform_get_resource() To: Zhen Ni Cc: ok@artecdesign.ee, Greg KH , USB list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Zhen, On Wed, Mar 2, 2022 at 11:38 PM Zhen Ni wrote: > It will cause null-ptr-deref if platform_get_resource() returns NULL, > we need check the return value. > > Signed-off-by: Zhen Ni Thanks for your patch, which is now commit 134a3408c2d3f7e2 ("USB: host: isp116x: check return value after calling platform_get_resource()") upstream. > --- a/drivers/usb/host/isp116x-hcd.c > +++ b/drivers/usb/host/isp116x-hcd.c > @@ -1541,10 +1541,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; Please note that platform_get_resource() cannot return NULL here, as this is the .remove() callback. If we get here, .probe() has already verified the pointers. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds