From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5083CA9EA1 for ; Fri, 18 Oct 2019 11:14:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 716BC20700 for ; Fri, 18 Oct 2019 11:14:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m7Y2tbrq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438064AbfJRLOx (ORCPT ); Fri, 18 Oct 2019 07:14:53 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39094 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725930AbfJRLOw (ORCPT ); Fri, 18 Oct 2019 07:14:52 -0400 Received: by mail-pf1-f194.google.com with SMTP id v4so3681404pff.6; Fri, 18 Oct 2019 04:14:52 -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=PdWA0N6LArMPxWcQPYXRVyly6m34mLC44EP1ORzmGqs=; b=m7Y2tbrqYomoSGGnsHw6ioheYXbdmj8e//C2iw7ChjohsJlP3ec3vNTpxwQRqMwQN5 RcicUxV41Cxaxc2+7F9PK2nnHiJtQLPABk/O9/moEEBVsYZzsZOsL/r31BA3G8ByazfL 5Ekl9xoxujTOTe/urEnC8wl3hRyAL64aCiPE0MKQhnlZ8gAYzURGficiDHU8m7rwBNNe 4SO38hPt4KgLNrwEB9zcKaZxiEz1NfYGHkwXlUjVtT5KlRRZEYtdWmPu4PgPLoG6j7RD ZHLih4EjQIUDQ8EttFo9q91I/BVNtxLro00YSmClWMBIlJj2fNoSK/AksN5Za1e5Tcrq slWQ== 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=PdWA0N6LArMPxWcQPYXRVyly6m34mLC44EP1ORzmGqs=; b=a8INU3d2Il5vyEgXNAIXSM35nIIOUxtryEVeT4to2BA3cvQ5bi+66Fm4EvpIppX84T 0r6MHGeNV9dFJ4o4JdzLYsYy2v1EMgDFPwcKeK6SZIZ9t1mWxrMXMF9t1UPS4rmDR5bT eewQllT/LWmy6eluXdvSMl9nuVa6ZoanJpwS7bK0X/US3taYw8tmEOvwVHsRjgnSe5IR CQv+AOya8GgzQLzn19nrKnfJoJMss5t+pRPnRsd0dqSCaRPprszEFAdTbFfWmkEk1cC9 vAtvoUX7oKoiswybaEKMQ2sgJqSl7yPy6sN2Dfl8hUcCoz6BGTqmNQoiJy7leM9au0TW JjiQ== X-Gm-Message-State: APjAAAWlAlBVOr3vvAfk8KtAvmEjKDmcLjAUdrsEtiu6qDn/JrT34bex LFAgUuw3Eyc0H1L0cUKLx+2HN/adiendiI1KilguiptJsHg= X-Google-Smtp-Source: APXvYqwiDaJWrpqwvInQO/35te4OjSHucMpHdYSAuAh5zBD8mD2bwLeTjsEtPWiayqiwXNGN/hjKBIdcLhBIbjZRB0s= X-Received: by 2002:a17:90a:9416:: with SMTP id r22mr10644319pjo.20.1571397292091; Fri, 18 Oct 2019 04:14:52 -0700 (PDT) MIME-Version: 1.0 References: <20191017025058.31528-1-hslester96@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Fri, 18 Oct 2019 14:14:41 +0300 Message-ID: Subject: Re: [PATCH] spi: pxa2xx: Add missed security checks To: Chuhong Yuan 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 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. -- With Best Regards, Andy Shevchenko