Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp483219imn; Wed, 27 Jul 2022 11:27:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vPhDELfh9AjFxHVBkqdGhxanRk5eD5tdJJz44vdGYcIBa248igYMd3T5912JT4u6xGQQ3S X-Received: by 2002:a05:6402:42d5:b0:43b:5cbc:eeba with SMTP id i21-20020a05640242d500b0043b5cbceebamr24005552edc.3.1658946463428; Wed, 27 Jul 2022 11:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946463; cv=none; d=google.com; s=arc-20160816; b=TEbpFtWnH9oGOC1EeulvTFVXNmXtOAg6tACrLt68FqgDBrufLb9sjJIvLM41MPea3S W7rPF+4BCix2zSpNZj2zeA1q3zmuuk1Dx2V5K7D247V03RAK1jCxE1RxpJUTfd6fPzzA UrMkZoyhaE5ZzPPCt9r7aUs20/uTSr1H/gnDFRBmhPP1bbVRtMYo840fnza6i2ko9JQh K326OUJb6YC0IKIDYoITnWXO4e6AqFjLcSrZystvfndmTQaps+tYRpuStY4QHawNaak5 ZxiY6nBNOmDft5opkNrMQpCDV4CD5RJF9P79net7ePM6gO83h/T+0oKrVdudWzbl0Fhk AkxQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kMXjV3Mp5IwMC5IXLWIwJTpB2wePryBOqs9y7iB4LnY=; b=pS5/U2QThjmBNar3Qkb5GwAqhhmYrBGW6thtR4D77ZvKIyA6hvsCf/sfysRMdmE1A1 4W7d9KIwf5yEDdK7XX1iGPtcFbhGdhWrWtKAhBFuQpiCjHVUiMgss/AYc1W7KOAZawHH j9r1SzOa/tMVse26hUegw+RrEnGfceKeOmUc+nQbWDS8wrVaHCZSAbPIrFKhbPXtJKMe vP2pe4lgsb5pFTwEGb5L9yyyszyXohin62YqLZ5bUHpTIiADv5w0zIlsEDkreMiGqBh8 NU1N1dtndtcC7b/93tGbsA4a5COPEfFvxb08wFhKIgakDuf5MVvM4EzQefbqhkkNINC9 ma2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ohJ5fksW; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a50998a000000b0043b52adbf6esi5725798edb.557.2022.07.27.11.27.18; Wed, 27 Jul 2022 11:27:43 -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=@linuxfoundation.org header.s=korg header.b=ohJ5fksW; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237253AbiG0Qcs (ORCPT + 99 others); Wed, 27 Jul 2022 12:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237774AbiG0QcI (ORCPT ); Wed, 27 Jul 2022 12:32:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE59752FF7; Wed, 27 Jul 2022 09:26:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 58E3BB821B9; Wed, 27 Jul 2022 16:25:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9ACF0C433D6; Wed, 27 Jul 2022 16:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939111; bh=0shjkcSBi+T8g6LRNkb44QHNKoxRXpDclFPnVHF93Kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ohJ5fksWyueltRhV5fabtn3japyvlNQj19Vg1G6kJdLMbtOl+bYmCO0dFGjbs1hhx ORsALQhp2NzZ+p/Tj2pgncPGVLQ0sJpZ1FBMaGOVUZLGCAmOyMUbaajgOCI2mR6RDa ov9Lsh64XD7w8sRBo5NRld/dl67n/bu1tdrbTsqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hacash Robot , William Dean , Linus Walleij , Sasha Levin Subject: [PATCH 4.19 05/62] pinctrl: ralink: Check for null return of devm_kcalloc Date: Wed, 27 Jul 2022 18:10:14 +0200 Message-Id: <20220727161004.385752294@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: William Dean [ Upstream commit c3b821e8e406d5650e587b7ac624ac24e9b780a8 ] Because of the possible failure of the allocation, data->domains might be NULL pointer and will cause the dereference of the NULL pointer later. Therefore, it might be better to check it and directly return -ENOMEM without releasing data manually if fails, because the comment of the devm_kmalloc() says "Memory allocated with this function is automatically freed on driver detach.". Fixes: a86854d0c599b ("treewide: devm_kzalloc() -> devm_kcalloc()") Reported-by: Hacash Robot Signed-off-by: William Dean Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@163.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index ad811c0438cc..031526cb1b21 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -267,6 +267,8 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) p->func[i]->pin_count, sizeof(int), GFP_KERNEL); + if (!p->func[i]->pins) + return -ENOMEM; for (j = 0; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j; -- 2.35.1