Received: by 10.223.164.202 with SMTP id h10csp2837753wrb; Sun, 12 Nov 2017 20:09:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMaUSwQfoRfam5c/YwoECj19mvUeASyifL56G88Jurroi7BaJjkQe9SLihKxzY3xsZJ6PJdv X-Received: by 10.84.131.40 with SMTP id 37mr5784430pld.302.1510546186640; Sun, 12 Nov 2017 20:09:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510546186; cv=none; d=google.com; s=arc-20160816; b=peEt5BIWdBjiNfRa6eJhyajVGDu0DvE82ig4M7ON68D2S1KK9na8WnEUV7VMkisF1O TgHiFA61neBew6Q4lc+7hN3y1u4PezuTQmpWrG/ujNjFXMf3FUdQmy/dovu+Pc43EmS3 wL84BxCbLu1FiG+Bt05nNllkfdjS+HS/+YlHgrMigDyW5KkfofyBPY1VRrtRvw9plpXE 8MOop5i/ajpRZkt+gHtYzc+qqx/MPlRpPz8o8wvZJI0vdnIlWRDaY12R+baP5wZOfIb3 TprrTk1J9Jw7pJ74235cOjMMuWb/A2AJiezw6OLgoT3O5/7TfBFjzmpOjKsLlDmlSrfL GLRQ== 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:arc-authentication-results; bh=6Pye+1Y34KKKa6ka5BVdHH+LqDcFW5aBSfC7Ewn/iKU=; b=H62KhyXwglKiPLr2rks9nLCHibeAUbTnZVKA/kA6M3Omy5/L83VF0sC9C2dKxAiyqP FnywrfRcGvzSkOJERhNgsvumfcRobnzzxjpaIpwbxMYw7amm+MTwWgFyy48K2MRD24o6 hqlo0mT43hGFdfOw4ac1Fi82Du8d0t+0Xk0o1b/Xub5DQ1h84NHYhm88oRUg4jmr05zp 3wEE+Q2SoRG8wi9p+oez1uq1KB6D1On1+Z+J0XF+kyXc1OPrypJK43Dtinc/sF7PO6pP d/j0GdNKsYaNg2mqNVCrsolDQ3GncpQ3edlrbiiFAFW663cIhw6R3HFms7LOtL3MTujk T/KA== ARC-Authentication-Results: i=1; mx.google.com; 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 ay8si12936694plb.78.2017.11.12.20.09.34; Sun, 12 Nov 2017 20:09:46 -0800 (PST) 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; 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 S1751861AbdKMEI4 (ORCPT + 87 others); Sun, 12 Nov 2017 23:08:56 -0500 Received: from anchovy1.45ru.net.au ([203.30.46.145]:45158 "EHLO anchovy.45ru.net.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751653AbdKMEIz (ORCPT ); Sun, 12 Nov 2017 23:08:55 -0500 Received: (qmail 7876 invoked by uid 5089); 13 Nov 2017 04:08:52 -0000 Received: by simscan 1.2.0 ppid: 7577, pid: 7588, t: 0.0667s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 Received: from unknown (HELO ?192.168.0.122?) (preid@electromag.com.au@203.59.230.133) by anchovy1.45ru.net.au with ESMTPA; 13 Nov 2017 04:08:52 -0000 Subject: Re: [PATCH] net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional To: Pan Bian , Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <1510501089-9451-1-git-send-email-bianpan2016@163.com> From: Phil Reid Message-ID: <251e5e33-8bbb-d745-63c8-95d7b34d95f0@electromag.com.au> Date: Mon, 13 Nov 2017 12:08:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1510501089-9451-1-git-send-email-bianpan2016@163.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/11/2017 23:38, Pan Bian wrote: > Function devm_gpiod_get_optional() returns an ERR_PTR on failure. Its > return value should not be validated by a NULL check. Instead, use IS_ERR. > > Signed-off-by: Pan Bian > --- > drivers/net/dsa/lan9303-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c > index b471413..6d3fc8f 100644 > --- a/drivers/net/dsa/lan9303-core.c > +++ b/drivers/net/dsa/lan9303-core.c > @@ -828,7 +828,7 @@ static void lan9303_probe_reset_gpio(struct lan9303 *chip, > chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset", > GPIOD_OUT_LOW); > > - if (!chip->reset_gpio) { > + if (IS_ERR(chip->reset_gpio)) { > dev_dbg(chip->dev, "No reset GPIO defined\n"); > return; > } > Should not an error actually report the error and error out (ie fail probe). But a null is the optional return and ok. (ie when -ENOENT return from sub gpiod_get call). IS_ERR should be a separate condition check I think. related lan9303_handle_reset() always returns 0. lan9303_probe checks lan9303_handle_reset() return value. Probably should be checking lan9303_probe_reset_gpio() instead. -- Regards Phil Reid From 1583886067017678448@xxx Sun Nov 12 18:31:02 +0000 2017 X-GM-THRID: 1583875313307114870 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread