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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E3ECDC433ED for ; Wed, 7 Apr 2021 16:19:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABFC6611BE for ; Wed, 7 Apr 2021 16:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354278AbhDGQT7 (ORCPT ); Wed, 7 Apr 2021 12:19:59 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:56881 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234460AbhDGQT5 (ORCPT ); Wed, 7 Apr 2021 12:19:57 -0400 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4FFBBC000C; Wed, 7 Apr 2021 16:19:45 +0000 (UTC) Date: Wed, 7 Apr 2021 18:19:44 +0200 From: Alexandre Belloni To: Krzysztof Kozlowski Cc: Nicolas Ferre , Ludovic Desroches , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] memory: atmel-sdramc: check of_device_get_match_data() return value Message-ID: References: <20210407154447.70540-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210407154447.70540-1-krzysztof.kozlowski@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 07/04/2021 17:44:47+0200, Krzysztof Kozlowski wrote: > If the driver is probed, the of_device_get_match_data() should not > return NULL, however for sanity check its return value. > As you say, there is no way this will ever be the case, I don't see the point of checking the return value, this adds 12 bytes for nothing... Maybe coverity should be fixed as there are many drivers making the same (true) assumption and I don't think this is worth the churn. > Addresses-Coverity: Dereference null return value > Signed-off-by: Krzysztof Kozlowski > --- > drivers/memory/atmel-sdramc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c > index 9c49d00c2a96..e09b2617f63d 100644 > --- a/drivers/memory/atmel-sdramc.c > +++ b/drivers/memory/atmel-sdramc.c > @@ -45,6 +45,8 @@ static int atmel_ramc_probe(struct platform_device *pdev) > struct clk *clk; > > caps = of_device_get_match_data(&pdev->dev); > + if (!caps) > + return -EINVAL; > > if (caps->has_ddrck) { > clk = devm_clk_get(&pdev->dev, "ddrck"); > -- > 2.25.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com