Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1731241ybg; Sat, 19 Oct 2019 01:16:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwS7lp2acNEAAUFiGkTb+q3I8OX8GPSXLo70r7Wj8MxUtBM2OfFIOzuqzQ7nk9VhfEq3BZg X-Received: by 2002:a17:906:f110:: with SMTP id gv16mr12771573ejb.331.1571472999324; Sat, 19 Oct 2019 01:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472999; cv=none; d=google.com; s=arc-20160816; b=1Fhf1mgCV4ynXIwqEPwTBeK0uURnC0taBptTTNalHdT8YnoyiYLs4JamyfDXAz2z3s w4+7i6BoIf67S0X/LSDHpGk++n+OIfdAIAL8mO1h3s+tcQp3GYrabK0+FSS13MIINVUT gZivjIW8ds1QUIKTCPypfqS4qUjPioy2TAxXAsPl+GT3nIhd87msRvETBtCIf4VmnD1S qL57VlMRBSfkrPpoStIrFQZxFlH8QFa+v0pvuNs9EkmcnDMEtUc/8xI7FJgFjZ97SkEZ u4pdp1FawZW09y5BGKjfJx+FVBtfc8223/rYu0M3qJv+l5F3Sr4I22v+SgTZx7wdobif YmwA== 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=PdWA0N6LArMPxWcQPYXRVyly6m34mLC44EP1ORzmGqs=; b=tRDWgkbFDQzHcPvCEF6x03ypJyYPVYsU3PbSYvIIjXti6fHalnIeBSDH9cX2gNI5qB HUOMDPN+pzJ7uNAXAo/5bilCVQKvG5jwN3mk1BPLS5rO17e3QOmbnysKxhIK+MrCuAYi tRCQuAefdVgqWpcYc8N08+uLTfp59eWZd6/gpA+6UqeBdJsAnn7t694TRLtJVfd4M7qD p9wFulYWZW+4oMs/SxRm7UWnLUnz8SOjeUPXD9TQtmmALkmbgJXdATS15SoWJIdEcn2g qG6YKrxnB6uZ3vsOtNzVSfDXbGDM93ja5VrB6DThFilqls82omyP8Lq9GiN5AfQPql+t 3UTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m7Y2tbrq; 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 l9si4553238ejq.164.2019.10.19.01.16.16; Sat, 19 Oct 2019 01:16:39 -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=m7Y2tbrq; 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 S2404247AbfJRLOx (ORCPT + 99 others); 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-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