Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1733684ybg; Sat, 19 Oct 2019 01:19:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6ihS2ZzNE23AKFrZ/RoF4+fenJcCRtDZt8NSR7qltN2OCfNSzuI2eWdi82egR1GlQFuic X-Received: by 2002:aa7:d304:: with SMTP id p4mr13962682edq.224.1571473194472; Sat, 19 Oct 2019 01:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473194; cv=none; d=google.com; s=arc-20160816; b=jPgI0ijwFcyQGAQ9uek7qZueyMEfCxVJPqkf183xfzG2ldz9CY6x6GYaShecnH5Xo6 pduq17v7hZG2lyavhKdnPhZ/eej82I4EwbwOnAHHyUar9IuX0r5MS/55miL+ku4CI67Z WaJoBgk04T2TIC+UEiJLKUvJuB0JTKPX2hCDnsCyxqtVgzookezgQJtThosbKkXJyOk8 jfE0RrbNMBUX67yg89PAJO8gUrwSbZFti3FNVj+0K2IX9PBbcWdmoZGbD6BjSNIvcQTz Jz5PDxj9wnoJHVMcOm0WmhSgd96Wccc9LVJA4OZBTQ4ZSLSjBa10+8jPRInUVb3z9hBt IZzg== 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=vfacdRIZROtgaYKyvVVlViTaU4E6jqDJejGD7tuz/+s=; b=hxC2oVnMys6EUk24KPKNzaSf+rDBK09hQsVqeyc0NKCxHF2SEETa/DT2WWo9elIQCl 8Cm6ZJfLj5uS7KsDERTF5Iz6Erg8cTIqGJ4efn7a0ef+XfApLD6bzqHzcvLwU9u2Dw1S 5RzEzJx5b9yKyBVZNt22u2vTnmqmjqu4vmOnDa2AaPhwC2cXvhwjnQ9adV0JIXfF7Etr ElpY6OKme4hCh/A/7xnKTVNc6Z3cndifx0zL9/iNMxeXkKNHxpbBuGvLT0nwk5I0FU5t /G6Hgd4IIRQ6vVD60ojaOai3ZOwyXhaF16pAyh51J88/lmPR39DbWqhxFtnx0NYYLyFG DQcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="TvUQBq/N"; 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 b42si5505440eda.367.2019.10.19.01.19.31; Sat, 19 Oct 2019 01:19:54 -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="TvUQBq/N"; 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 S2407113AbfJRLhO (ORCPT + 99 others); Fri, 18 Oct 2019 07:37:14 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36652 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389955AbfJRLhO (ORCPT ); Fri, 18 Oct 2019 07:37:14 -0400 Received: by mail-ed1-f67.google.com with SMTP id h2so4317737edn.3; Fri, 18 Oct 2019 04:37:13 -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=vfacdRIZROtgaYKyvVVlViTaU4E6jqDJejGD7tuz/+s=; b=TvUQBq/NsvkK0uCyK5aaB1cOiOq38Cq7pGNXyhyOMe3ai76NPGio2T0PBOiFlsDSLZ R1sshtOTbas68n6dMsqEFSXVaqG4IevQuXPdjVu1uEIG6biMwYUGzfYiYtAI82R/BHDQ 93FUxB1OwxHTphdgReKffJfPJ+UwhufDFKK7AoYI7qJrCzkXl1ewHruSYOkaAv7oZQPf qROubUq5dNJqlQt3Jn6QT3+p36Ij8wTlbM+kF7U05qeTtXpOV+L19PUsMIm32ErniBaY Ed2mj1G6gOS6Tuj2Nzck3c4Gx2RKyCehPdoOBwpR1QSXzbSyeJ3MjUCkprA0q8skNpxR C/UA== 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=vfacdRIZROtgaYKyvVVlViTaU4E6jqDJejGD7tuz/+s=; b=ilfIHWBw7gukntxxwviQUyknN7wT3K9ax9eAUnZjBqg10HcXzD0MiZctaOJezGNkoe pnmQz4HkUh5h45Z4pOh+7Jugn8Dzlg9VuugYEc03p64gEYP/y/f7mAIJsXXOQ++zjyzY dzkIEnEVbnaeXR4Ll6xNNyQ/ETgfTHB5LzbhI5Mw/q2CjS2K1v91KokG4XDuj0Mu+yHv h/tGZBqVRC/GxfRDUtZyTnDeqfaiOqfpO9+vanA6CUYghZCioIjIzHWdhYHjEi3tQ17e EJuWpul7CRyC2y2frKHMClv/DpgfOSdudC9hghNrCgP2XTv337VJyS7gvx0hX8F10IZR Fw8Q== X-Gm-Message-State: APjAAAWDlfSnAVz2eMVESANfePY3BC1w5B0A2iX9HGh/mRBE7lxD0a6b 2c7Z763uCfk9Fj11B+0NX2cvwlGJTktso9y9MuY= X-Received: by 2002:a17:907:4182:: with SMTP id mz2mr8019392ejb.326.1571398632465; Fri, 18 Oct 2019 04:37:12 -0700 (PDT) MIME-Version: 1.0 References: <20191017025058.31528-1-hslester96@gmail.com> In-Reply-To: From: Chuhong Yuan Date: Fri, 18 Oct 2019 19:37:00 +0800 Message-ID: Subject: Re: [PATCH] spi: pxa2xx: Add missed security checks To: Andy Shevchenko Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown , linux-arm Mailing List , linux-spi , Linux Kernel Mailing List 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 Fri, Oct 18, 2019 at 7:14 PM Andy Shevchenko wrote: > > On Fri, Oct 18, 2019 at 1:39 PM Chuhong Yuan wrote: > > > > On Fri, Oct 18, 2019 at 5:35 PM Andy Shevchenko > > wrote: > > > > > > On Fri, Oct 18, 2019 at 8:59 AM Chuhong Yuan wrote: > > > > > > > > pxa2xx_spi_init_pdata misses checks for devm_clk_get and > > > > platform_get_irq. > > > > Add checks for them to fix the bugs. > > > > > > > > Signed-off-by: Chuhong Yuan > > > > --- > > > > drivers/spi/spi-pxa2xx.c | 6 ++++++ > > > > 1 file changed, 6 insertions(+) > > > > > > > > diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c > > > > index bb6a14d1ab0f..2e73d75a6ac5 100644 > > > > --- a/drivers/spi/spi-pxa2xx.c > > > > +++ b/drivers/spi/spi-pxa2xx.c > > > > @@ -1565,7 +1565,13 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) > > > > #endif > > > > > > > > ssp->clk = devm_clk_get(&pdev->dev, NULL); > > > > + if (IS_ERR(ssp->clk)) > > > > + return NULL; > > > > + > > > > ssp->irq = platform_get_irq(pdev, 0); > > > > + if (ssp->irq < 0) > > > > + return NULL; > > > > > > I'm not sure they are mandatory for all platforms. > > > To be on the safe side, you simple need to add _optional() to the both > > > call along with above change. > > > > > > > As I know, this is the only one in spi which does not have a check for > > devm_clk_get. > > For some it still may be optional. That's why better to check it and > mention in the commit message. > > > Even if add _optional(), they still may return errors and need security checks. > > Of course, see "along with" in my previous comment. > Got it. I will send version 2 in which both _optional() and security checks will be added. > -- > With Best Regards, > Andy Shevchenko