Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp12780iob; Mon, 2 May 2022 10:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz22bV1auVFTjfB8wgenl9ngSAyx6JORcbNUdMHagRZ6wrJgI/7OvpIm/2RcQwCU+31goeF X-Received: by 2002:a05:6a00:1a49:b0:505:7ab3:e5c7 with SMTP id h9-20020a056a001a4900b005057ab3e5c7mr12180648pfv.62.1651513567770; Mon, 02 May 2022 10:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651513567; cv=none; d=google.com; s=arc-20160816; b=lYAmY5n7ItA6CsV1u5bRRFRxT3PoqjL0m6aW+UYQgHMN91tuIaDtr5iFNpZTJB3JeF +NjcKRI2igyAyUVBaZF48M8N2isTRyIesXnEqPx+T6ITgcETo2W+ThrWTcg2KkqZd7oE TDJz0qnp7yEpuiUxf12yyLcrbKzmzBQ2pFKU3lSdOVH1NsPUtOvl1gms+9DtMWcLTVvF kpbBdMqEqopL9/cRDByF/SS0EtoZnWVme6++Mk5GYuX/nnxpj07jWV8Uwvl3w5pGVWCB vNwWk/DzPOT3Vd0u9SJeZmZ9Sung9dT8Jxxr7d+Rb8QdMfoe7k7uFih4iiBk/0EGyy7P SxBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ks7iNdCfAtLHcGFxak97bEFI2RXZViTgEPfvTdzl5nU=; b=c0VvOpIGpV/jA6qKnDkERu88iSY6rkKu73VGlrDc6XNX6//GjvkN5uisQTV86f1Cl1 DtSDCKinksuuL16gQDvWfZpsSvPkV+YF9HsPCQI13lZWqaMtDEwSUsfEuS/McSe3HYaS IVFBykbHHaxcSqKChzPdp3HCdNSKD+7EMDdnOw9dSlNzD7KZd7lWtRYUza1lszxG0W7i Ck7dKscmNLLs1R4I5nPvyy0AGrposVixT+RvpOmZtwu0i31QZ5i9+jSOYBGJLyLxcdqB L2G28n8d/mZTriuS7xAM1WMH1aYi4HIl0DF2ZbPX1Pg7VDaEOTh/KBocMCObZPoX6C0a gvtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcrihyw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a65654a000000b003a84836e1c3si14570645pgw.363.2022.05.02.10.45.49; Mon, 02 May 2022 10:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcrihyw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379221AbiD2Qb6 (ORCPT + 99 others); Fri, 29 Apr 2022 12:31:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379137AbiD2Qb0 (ORCPT ); Fri, 29 Apr 2022 12:31:26 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0767DA6C7 for ; Fri, 29 Apr 2022 09:28:06 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id i5so11435230wrc.13 for ; Fri, 29 Apr 2022 09:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ks7iNdCfAtLHcGFxak97bEFI2RXZViTgEPfvTdzl5nU=; b=dcrihyw7I+gZu+S9NN3riDHd9b3CQ04ZfaxESSQCra//U0lJECoeySkwNG1ude/TfU A9U4vJoBKQnOBaLGhcOFfOdVRT5FZRUtBr2rCsHFb1//NoCz7/rdNckOpZKl71M/vv1h s2iX46rrsmoNvC2LYA0yeNVHp9bnvcxDhSv/9Uc/MVJ1dymfBh5Uq5J3WFaxee1WC5kl IVA8+ZApuQpdXQfc25lBu1fusenAcdO+tCySnaB5QtvsZJcnSSy1m80bO/22Mt1muRyE 7CqtPAput/GLy2JgMyw6Le8/F6UoRk91Cd/O/NzpY522avBwU6IWUtw5Bi28Gnrr6Q9X N8ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ks7iNdCfAtLHcGFxak97bEFI2RXZViTgEPfvTdzl5nU=; b=mcwn9GKZzw07DKMidoAK7qbU7vR8ds9ATcIzOxaYqYmt73VfaY6RzzEEhXx5eZjlbk njqBc2tj2L95doJTvjcgy3dwCupBwPrSLOqxO6q8dKMzH38X3XNvREmWaT+Nd6jclnUa TOqLQsQ0mqXt7TXHVZD+S6pRPYsHXhr7zq81L9ZnIb1k3kByBf7lDuvgDal9UQQ8Jh90 gIzwdKcuqUYvChNrDu+TcIeEp9fzpn36knWMFx4lrKtHzsU7Y5sbcwFpazmftcnDobgj gRH4qGXHyHeQ+IbgF3aApkNceHIWFhxAbluTEp037ibEurSrc+yY4CseZY7+g4ctAtt5 XqgQ== X-Gm-Message-State: AOAM532X/pQG86BkrdKUOeCUyki9rw9IZskq9gutE6Nnfmc/cPcZhsol mjyM2+1uJsS1AYbFWjkPe0c4ow== X-Received: by 2002:a5d:6c68:0:b0:20c:4af0:cad9 with SMTP id r8-20020a5d6c68000000b0020c4af0cad9mr2694501wrz.41.1651249685564; Fri, 29 Apr 2022 09:28:05 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id b5-20020adff905000000b0020a8781be70sm2781801wrr.12.2022.04.29.09.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 09:28:04 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Dan Carpenter , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Srinivas Kandagatla Subject: [PATCH 10/16] nvmem: brcm_nvram: check for allocation failure Date: Fri, 29 Apr 2022 17:26:55 +0100 Message-Id: <20220429162701.2222-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220429162701.2222-1-srinivas.kandagatla@linaro.org> References: <20220429162701.2222-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: Dan Carpenter Check for if the kcalloc() fails. Fixes: 299dc152721f ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells") Signed-off-by: Dan Carpenter Acked-by: Rafał Miłecki Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/brcm_nvram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c index 450b927691c3..48bb8c62cbbf 100644 --- a/drivers/nvmem/brcm_nvram.c +++ b/drivers/nvmem/brcm_nvram.c @@ -97,6 +97,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv) len = le32_to_cpu(header.len); data = kcalloc(1, len, GFP_KERNEL); + if (!data) + return -ENOMEM; memcpy_fromio(data, priv->base, len); data[len - 1] = '\0'; -- 2.21.0