Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5071306imm; Tue, 12 Jun 2018 01:56:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLGfU30wzW5WcF6bCmR68DeStdAm5bPgRNpXJDV38FlbjJsyajB/SbB9WgGPZXTn5H6iZHj X-Received: by 2002:a17:902:7484:: with SMTP id h4-v6mr3050842pll.154.1528793778427; Tue, 12 Jun 2018 01:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528793778; cv=none; d=google.com; s=arc-20160816; b=gxhEwnNWOTOAXBzzr1lft1w0PgE4Um0a6/eHkXzo/yW8ZmqONjFxQ10I3wpOnppRl1 2h6kTjGc+pkksdNP9BOS4QfG7OTRyIpg9tYkmUgn6ao6QIpxAmANH45VWcF5Ru5htf7W ZSnL0C20Ym0eOUfMo/M0W8B8IWz+8YVLfE/4h5p33QITs17w/oWKEvb0grZaBLB5Fuw+ IjPgSgp9ye7QHu6P6kOaFMrIpyUOPbGg9Rn/Lap0Vv72hklVmuCcBBqp7blAHW5jfM1+ /JJ/jdKE0d1RyC7X6Z+Th6nujyuNU1vSVXAk0SKEZE/FP6SuY1jkcQiZendH9Fn6zuQ7 wC+g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=nYNRHA42EcASS3/6XHKUsdYlCMp9OvXIbZbySr/3NIM=; b=SFvh+/lps/pH/F+4CjdOOK7qkHh5ijLZ1dJrB7lEm1eX2ln2y1mYrVR0pHUMgcXT7/ tkUES/r/yVCkNeEu01IAO0rV3NNvulfG5Byw7iDsBoPPdxPzKkoHsZ2WlkOmwFHfyn+T 6JBfx/MTQN1WOVvgsBXgMKGW79xfvsNIoxlQxj0lA0JtF8d40luqFLCI7bLy0Kgs2MCY rKVfU1uilE3CoXeU/+aeTnEClvlnInIp+/uXlBZjsy+RxushAAJEKvswh1AGp8nC5rRw TLO/57m9roaH4h98cP32t+ZHMaoNZPwCxBTga9o0xBG4yRaxdx1E0WoLKZf9abtZiP6q dCgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=Xr1hYw2z; 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 j191-v6si349691pgd.7.2018.06.12.01.56.04; Tue, 12 Jun 2018 01:56:18 -0700 (PDT) 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=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=Xr1hYw2z; 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 S933938AbeFLIzR (ORCPT + 99 others); Tue, 12 Jun 2018 04:55:17 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37276 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933857AbeFLIzP (ORCPT ); Tue, 12 Jun 2018 04:55:15 -0400 Received: by mail-lf0-f67.google.com with SMTP id g21-v6so32808555lfb.4 for ; Tue, 12 Jun 2018 01:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nYNRHA42EcASS3/6XHKUsdYlCMp9OvXIbZbySr/3NIM=; b=Xr1hYw2ziEui+NLnr4Lxl8bTmrF2kiij8unvAt5rkD1cH4LR9aV8PvJ0p4NpzJP5ip qOhO6N944GAiFby8onUWk95G0Kg4CoDNQSlvfxp8GrwLWXpeJK4CIp8rWzc0NtbL80Jx Ja0OGu6+LfwdoWhag0wIsGvjlA2v9+3DvNOcyDaYQ83PnItvywlzgcGEeAmj3o55VdnJ eH5h8zn2tdWXkTIEGsSdsqOfVlm6dpbLFfJj7ebUWanKGWpS0db2u6Qq+R8D7sOPXes/ NncvDk5qcVh+a/SWQm671pZEO3YMmRjq7s5lncUAHC4+CTqblo7Eh2EQH77TtRUiGb1j iXMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nYNRHA42EcASS3/6XHKUsdYlCMp9OvXIbZbySr/3NIM=; b=K9mvWaBaNrePbulATrtYG1y9PvJI48S0Az6omFZ8XxCnBgzUtbBHQEQRo+3HflEvWo fpm/Uz6rWmTS8pNR7EUKlchD5vvzryTJxOI+haM2DcaeMTmJfnAWxbK/PC8GGDuhNVU5 Kis8RnFWQq9pNZ5mDrA3asWvWw0I+szIuxjgnrxVMLjrOhBl8NG7fku8N5OwjeN6XrPp AbjF6lSf452ZOa4DiY7WJhs99p/Vjd3aA8ReZx6DAI7ODxvNVlwIuUJSOGryOh4a5vCc dRQTJg/z5p10wVIdZ0CddQvdkMGl638PmeKVSqoa5y9y3JS2ee6jBz6TNMx4Xq5TUF0Q bIEQ== X-Gm-Message-State: APt69E0swaahd1Xt7tXh2BfnEwxS5Cw7tod3UVR84vcVkfCB7ub8pCGO 4FLEnfhFLyp9fqWmxAlqPf2lMbil6fI= X-Received: by 2002:a19:e82c:: with SMTP id f44-v6mr1515212lfh.19.1528793714256; Tue, 12 Jun 2018 01:55:14 -0700 (PDT) Received: from [192.168.0.126] ([31.173.81.249]) by smtp.gmail.com with ESMTPSA id x17-v6sm95224lfa.10.2018.06.12.01.55.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 01:55:12 -0700 (PDT) Subject: Re: [PATCH] usb: gadget: add error handling for platform_get_resource_byname To: Zhouyang Jia Cc: Felipe Balbi , Greg Kroah-Hartman , Nicolas Ferre , Kees Cook , Allen Pais , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com> From: Sergei Shtylyov Message-ID: Date: Tue, 12 Jun 2018 11:55:15 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 6/12/2018 7:32 AM, Zhouyang Jia wrote: > When platform_get_resource_byname fails, the lack of error-handling code may > cause unexpected results. What results? > This patch adds error-handling code after calling platform_get_resource_byname. > > Signed-off-by: Zhouyang Jia > --- > drivers/usb/gadget/udc/r8a66597-udc.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c > index a3ecce6..a7bd5e7 100644 > --- a/drivers/usb/gadget/udc/r8a66597-udc.c > +++ b/drivers/usb/gadget/udc/r8a66597-udc.c > @@ -1830,6 +1830,11 @@ static int r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597, > struct resource *res; > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sudmac"); > + if (!res) { > + dev_err(&pdev->dev, "could not allocate resource.\n"); > + return -ENODEV; > + } > + > r8a66597->sudmac_reg = devm_ioremap_resource(&pdev->dev, res); This function checks for 'res == NULL', no? > return PTR_ERR_OR_ZERO(r8a66597->sudmac_reg); > } MBR, Sergei