Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2081480pxb; Fri, 25 Mar 2022 10:44:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkClUwUu5uwMdhEo++gBZt1MBxtnwvPNV7/VYS+fIxhqmFgYqNXKsifdaT/0UX8KHf9XVY X-Received: by 2002:a17:902:6b47:b0:150:1f58:44c3 with SMTP id g7-20020a1709026b4700b001501f5844c3mr13215644plt.127.1648230287593; Fri, 25 Mar 2022 10:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648230287; cv=none; d=google.com; s=arc-20160816; b=mBcNt/N+hQFyRtIFWbS3YUy9o7TTykH4ya5a3Jv9KUkKXGwRRL6BkywAy7Ymb7HYC4 v7lYcPur+5x/u3zYrMhLt0ITLaEdNB8KxBq+UKTIeK+NoLJZ9409DclKKFGOjjBGGNK6 BBDsBoxLSt31AyPsUlFZJqGom+7req6r/E/EmDMbZzSG2JS74PlXmaZPobqaD5xkCbVp iYzWcuzvj3mpfSKNDQmuyXuUJG4xO+Np3/AaopvqlZGqvrgDLSD1HOp6vI1QahCm0vS2 kC/HdT2gQJS4270s+SSn6Vd1gHBjjRsFrywMGxMCcpJIRvBxyoeW4ICvJxrU0uLaiouk BnsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=STMU7e/I1m6VY6MjvIoI76oz7x7+nWXzvbO+4NLxw0s=; b=E17NfD664JFEuX/wIL3kt6Q+rC5bz+4B/1xOJzYch03YgjYEuRASycJNvPoE5EGJam lzwlOKffctso3D0QhSWx7Cf3IWEtWINwmZZVYfpG6i4lIiUGrKCOMPxuxYWQqoPrivVq BCTX7FZiYVwd5CuAX4q7LLm8o1GpUZLj7PNGXy9LtfDuFY42xDs3J93qf3WFHwdS2bna zYTnOLNk8tIl5GgVts3/5wGS4P4SsHC+PVbrKBBiviT5VP8+CdZ1sIz7TtiOwcjXnb8x GvxpbY8DeGvnsbtMPDU42XcccnJG0DJjoJQZM/MYzJ9SHBZPn4Dfd9M1e8YdxdBIrPr5 OfZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JSTzQSr8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id my15-20020a17090b4c8f00b001befccfd1b3si3256324pjb.181.2022.03.25.10.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:44:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JSTzQSr8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F2CC118630; Fri, 25 Mar 2022 10:31:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352073AbiCXRGV (ORCPT + 99 others); Thu, 24 Mar 2022 13:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352006AbiCXRGU (ORCPT ); Thu, 24 Mar 2022 13:06:20 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCCCB0D12; Thu, 24 Mar 2022 10:04:47 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o68-20020a17090a0a4a00b001c686a48263so5775773pjo.1; Thu, 24 Mar 2022 10:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=STMU7e/I1m6VY6MjvIoI76oz7x7+nWXzvbO+4NLxw0s=; b=JSTzQSr8a6ZV3CML3sQN/TWvPdbiQsTWJhG0wSSRtNr0MFPFt1eJMYS2u2lUa8X2y9 8CYfd1wDhQl103rijG5UpmGdXeQ4pGUS8aG53v0DKJkfJfjt07wYbCJz9Gfq4rTBJCSH cD8mCnXDywf1XZ9SEnt057QMM2oEW5bKnaV4Umj8uzeFpFdLPtT2QKmmy2ehyqQu1aDC QIdajoXJydC8sFtFi+654fInQ/JC0tCP4c7AByNs4AiZffn6jBZ6S+PheMInlG6EMqWn V1a+1Ikd4oIomJWbiqplvpXvoDsIa0sDeq+JchDAwg7ytkRWxblCXzCqN2mfP3JN+g3M EJ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=STMU7e/I1m6VY6MjvIoI76oz7x7+nWXzvbO+4NLxw0s=; b=WALNx3kgR2ApQsljmFtpA9f/+YvQWyZs3cABsjyiCWoDM2BPwKst5W9wzu3ODgoR+/ TlOBzHaVhqnxDV2eAkXW8Z2krbW416HA80pFh/LGU8PP3NJ9i/M8LEi76hPiRVdgENqY +iLmwJHkBH5zLm39opJ2HT9ByAr5tm1ZEjYyIxWR0xIEoTP6lUaOH/OTKQok1aY4cYBh jauRI/TG5PKly+dczH5LMOtQg28d3V2M1g+3Lj44gdJDqu899pn9FvZ8saIw764EZgGr g+JHOBA0HTrTrU4WQrPOsLazpUT4rUoNHbxjA1/6KwsQQpA14ruY4gsrR0XFNTyTelH6 x98A== X-Gm-Message-State: AOAM531Y4HszFCwTtY7mt9NLRiVX1R+JJnm6zlKVTQwokUFJFRfIBfC/ GVmXEjt5xMQNGdp8auT9MGI= X-Received: by 2002:a17:90a:a78f:b0:1bc:8042:9330 with SMTP id f15-20020a17090aa78f00b001bc80429330mr19740927pjq.229.1648141486862; Thu, 24 Mar 2022 10:04:46 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id o65-20020a17090a0a4700b001bef5cffea7sm7331537pjo.0.2022.03.24.10.04.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Mar 2022 10:04:45 -0700 (PDT) Message-ID: <2a8afc70-c0d8-2b37-9d49-9a054a30ea4b@gmail.com> Date: Thu, 24 Mar 2022 10:04:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1] soc: bcm: Check for NULL return of devm_kzalloc() Content-Language: en-US To: QintaoShen , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: bcm-kernel-feedback-list@broadcom.com, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org References: <1648110940-4684-1-git-send-email-unSimple1993@163.com> From: Florian Fainelli In-Reply-To: <1648110940-4684-1-git-send-email-unSimple1993@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Rafal, On 3/24/22 01:35, QintaoShen wrote: > As the potential failuer of allocation, devm_kzalloc() may return NULL. s/failuer/failure/ > Then the 'pd->pmb' and the follow lines of code may bring null pointer dereference. > > Therefore, it is better to check the return value of devm_kzalloc() to avoid this confusion. > > Signed-off-by: QintaoShen Fixes: 8bcac4011ebe ("soc: bcm: add PM driver for Broadcom's PMB") > --- > drivers/soc/bcm/bcm63xx/bcm-pmb.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/soc/bcm/bcm63xx/bcm-pmb.c b/drivers/soc/bcm/bcm63xx/bcm-pmb.c > index 7bbe46e..55bf389 100644 > --- a/drivers/soc/bcm/bcm63xx/bcm-pmb.c > +++ b/drivers/soc/bcm/bcm63xx/bcm-pmb.c > @@ -311,6 +311,8 @@ static int bcm_pmb_probe(struct platform_device *pdev) > > for (e = table; e->name; e++) { > struct bcm_pmb_pm_domain *pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); > + if (!pd) > + return -ENOMEM; I am of two minds as to what the appropriate behavior could be here, we could equally use an: if (!pd) continue; or do what you are doing. > > pd->pmb = pmb; > pd->data = e; -- Florian