Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp507187ybg; Fri, 18 Oct 2019 03:14:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQXkwa9gJViR6qalRLopbe2mCUicwo4sF15QRW5uUn42DAhPXiBK3B9ECoiKFIcGB9QzXs X-Received: by 2002:a17:906:6a14:: with SMTP id o20mr7767152ejr.230.1571393651177; Fri, 18 Oct 2019 03:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571393651; cv=none; d=google.com; s=arc-20160816; b=BpF52X2OOd+Y9OSE1uWjXWjGco8+WvSoC10auCX+Z6uJxroU9orCHS+ZCX+HNLNK2Y +omoTv2oWomw4zN7cJbXIJFQuWvReQgDoSNX6v5lqkkBr4ntrGosel69E3k9j4MMf5hx plHtF+mB3Me5dEDgZ5GKg+eq8syduLq/bpMGHNMhpALC8OhHcPVq1ofWCp35CGaldtx8 /PMSJ2QWqRJs2eNpMnW/F9sdcl3Z9RLwwRuSx99lZ2iWJNptTYeuHXUUHbRE3vsIydFc OrT836jbX6mhErbBuqUgn/conya3hU2bpKOG+bC57h9dYGfKSH30rwhYOocLrHSyB42f sq8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8B+VL6RjXg5KMDSHhbVjjx3TQz+ogXFR8+wGExPxeGQ=; b=VfDc0tjjmtu5TOE2U7UC4oneRDXY+YIlUFiHS8Bura/iCnQxsY3LUPc8n31SsdaDGf hstHd/s2OqfBrce2KRgpgUMeyAQYXNjP5ZIM8HQxGMAuCusoGMQf3zKVNnPKPvuBSWct stac8qmA2dDx5m93DLem3L/G8CkJCuvGywZa0xF/la4h+zkPR0VdeGPjTjFj8rURsC6m ZMdHqVOO2QVkerRxBiddYMWgDSKre6CLrRmYQONuoyziLaw4gz3IuCDIfk1XFtBF1vCy YLvAslQ2SEhc4KApj/9hHLLPuoPStO12RfE3EIyKLp2gCl1jTAbbPza6yzehMOrj5HX+ JvFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qOCBOGJL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id me23si2954554ejb.344.2019.10.18.03.13.47; Fri, 18 Oct 2019 03:14:11 -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=@gmail.com header.s=20161025 header.b=qOCBOGJL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438517AbfJQHsc (ORCPT + 99 others); Thu, 17 Oct 2019 03:48:32 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33600 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387930AbfJQHsb (ORCPT ); Thu, 17 Oct 2019 03:48:31 -0400 Received: by mail-ed1-f66.google.com with SMTP id c4so979823edl.0; Thu, 17 Oct 2019 00:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8B+VL6RjXg5KMDSHhbVjjx3TQz+ogXFR8+wGExPxeGQ=; b=qOCBOGJLloO3vmyqaRI+6T72uldMbOQsHidQ6BRi2voae07zuY8uRplwWLvQULhXAq EnhD5ORTI/u17427MXfItSfVk86MDBU2dRcWm4hlr8ZZFxwSiYp/c6XF6OARVLEZviYF kGTgQFbtkjVo5BmhvtD9Ee7JuVIglLO4jxCUh2Vy7l0CRUXmrRdydt+Xihue/MAH9X6y ghpJmSx2ExE8r65ZdJyXWNBAbaIwqAnRojflSTV30kOrfqBZep5b0CJjh+9y0zRwVtMA djKD41iFnE5eKX1WXfVJR+OR8RaZvcbkt4GRNePH2E8fbIc6XIY2gOoCtwGbg/Ab6/ZL rM/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8B+VL6RjXg5KMDSHhbVjjx3TQz+ogXFR8+wGExPxeGQ=; b=lIETvUVjsKDYQI7Wn0ZB8lGELC7af379TRY4FRJ40FAiFnr2WS+nOCcdSpUPWrQNKJ kWc0XyKkj4EJZPM4vI3lBmhfCfNXS/9brRLHei0Taz+cSrzKbljoNauqFM92beGSgd8Z P32kWWZr5bDrooCV1T7vJjIRz54bZClTNgn5LYtTwntqlYUOovdpc148ta0JitqGF5Zf P5M2cRhCeJGaBIr57uMzQIaCAjM5YoEbm5lBA95SbyZiBX6hW+7htyuBgjuLqGfn/s2u G1s2rFZ0PrjawD5zSI7WZICvaC1GUytffsQly9UZ4xAm4nJqxLQ8OMabGQ9vRQUZ8JT+ G+6Q== X-Gm-Message-State: APjAAAWW/L5nYV3Lo/9jpisMd3GdA3k+tsKRtZSY89sTdlhRKWZJP+x1 nam7tDGFRw36bg+2+yr2aaSQyCLmCwztFyP02AjNO20m X-Received: by 2002:aa7:d410:: with SMTP id z16mr2360627edq.40.1571298509980; Thu, 17 Oct 2019 00:48:29 -0700 (PDT) MIME-Version: 1.0 References: <20191016105604.8036-1-hslester96@gmail.com> <8de93390-ae04-4278-bb34-aa175c659c23@st.com> In-Reply-To: <8de93390-ae04-4278-bb34-aa175c659c23@st.com> From: Chuhong Yuan Date: Thu, 17 Oct 2019 15:48:19 +0800 Message-ID: Subject: Re: [PATCH] media: st-mipid02: add a check for devm_gpiod_get_optional To: Mickael GUENE Cc: Mauro Carvalho Chehab , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 1:43 PM Mickael GUENE wrote: > > Hello Chuhong, > > Is this check necessary ? > since looking into code it seems to me devm_gpiod_get_optional() can only > return NULL in case of error due to following check in devm_gpiod_get_index_optional() > if (IS_ERR(desc)) { > if (PTR_ERR(desc) == -ENOENT) > return NULL; > } > And in that case reset_gpio is not used > The problem may not be a null return value, but a returned error, which is a minus value, like -EPROBE_DEFER or -EINVAL returned by gpiod_find in gpiod_get_index. In these cases, devm_gpiod_get_index_optional will not return null but return the error. Therefore, this check is necessary. > Regards > Mickael > > On 10/16/19 12:56, Chuhong Yuan wrote: > > mipid02_probe misses a check for devm_gpiod_get_optional and may miss > > the failure. > > Add a check to fix the problem. > > > > Signed-off-by: Chuhong Yuan > > --- > > drivers/media/i2c/st-mipid02.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c > > index 81285b8d5cfb..d38e888b0a43 100644 > > --- a/drivers/media/i2c/st-mipid02.c > > +++ b/drivers/media/i2c/st-mipid02.c > > @@ -971,6 +971,9 @@ static int mipid02_probe(struct i2c_client *client) > > bridge->reset_gpio = devm_gpiod_get_optional(dev, "reset", > > GPIOD_OUT_HIGH); > > > > + if (IS_ERR(bridge->reset_gpio)) > > + return PTR_ERR(bridge->reset_gpio); > > + > > ret = mipid02_get_regulators(bridge); > > if (ret) { > > dev_err(dev, "failed to get regulators %d", ret); > >