Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp483123imn; Wed, 27 Jul 2022 11:27:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sdIv03ufKFHupxHEKgfHrnzLhc2O4Hx/KBy2gm95AK7L3SE5uqtUlT2n/E2FeC49sZzSK+ X-Received: by 2002:a05:6402:520a:b0:43c:4ec:e809 with SMTP id s10-20020a056402520a00b0043c04ece809mr16002745edd.198.1658946455581; Wed, 27 Jul 2022 11:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946455; cv=none; d=google.com; s=arc-20160816; b=XF9sZ99Sg0fYL92f8ZhtpFx4IX9RTWFA3nWXBxkRTYKIzKsoCWsl0PkhMLi23Jyi4c o7EmYtqPCyqakQ/y/MgckcfjS/kKKh0oz9BRTxT2cgwRjOsY5+QiBjPwQYziCVVNSigR B+SrRsE1H9caeNH7zyUHvflYjV3oBZXkXY/dVQ5QGRCsWkEVop+88TUKdnpBflJGPoPu YKVyV/+o9OPXBHnvFDyyBj6mZxOGMjxoL3UpyUm3iLzUY+DC/OW031eHAgCjNGe8hh81 R936R3wEwQUV0rt282W4bBPI2GZ3/cSYpdcsqpRWBUUHy7N6B6mVGHtZ3puQWRwQxlHD 15QQ== 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=Bh4CTGeNaUhGIcvwMRV9iaTysYWNCBNQzDIyzNmPhMI=; b=jh1rRFk7+kAILkYvooOMUqoY7ThGKX4yS/mnwOYvJHHpG+nFxRX87Uj3uSMc3Groll FAV+QEEB9hHfvFhYf34MQmaaiYB3m2f5v5OuErrlnRc/8TnBehCb/pGzO8Ogr759ZKEs t69qgfj5DgelHMspLzEpuGKrKdcO2z0mpfCavuWpsmehJQ0QFjCm/U3RVCky/Sk2UqHO pW+Ey0NonV2FilhTZ9+zJXPD0pnhCQIiQvyMHICajgKR43M5yU3qXZfB6mQ0KO6r5wp1 KRj+C0k7Mipd/W90U9LzyI0hyh2ijDsws475zrJDxZh44tp4TSSK2t8Bii43gW12lAx1 Rw6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qmi6dzNK; 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 d15-20020aa7c1cf000000b0043ccd6ea840si1131718edp.358.2022.07.27.11.27.04; Wed, 27 Jul 2022 11:27:35 -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=Qmi6dzNK; 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 S239187AbiG0Qjx (ORCPT + 99 others); Wed, 27 Jul 2022 12:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239370AbiG0QjN (ORCPT ); Wed, 27 Jul 2022 12:39:13 -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 DCB725A2D2; Wed, 27 Jul 2022 09:28:49 -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 5F444B821A6; Wed, 27 Jul 2022 16:28:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C602CC433C1; Wed, 27 Jul 2022 16:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939328; bh=fZCRhPWBOFQUBqV5FF//jX1LfJGFpbtLedILZSXCl8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qmi6dzNKf6OSxCEqJQb+bl02DlNWkf2WxwSfOHFNT5PDLMQY1LhWZCYsnzYX3QP4S 81geYRO94Fkn+txAyN2ju5PQIuuGFT0M8sGfBFwIdT5FUV0DDlYhu/IM58tz3QOf8a 5SXFXvsWiSVoTXB6dIy/RRbgsDMuihNNzI2J+Z/U= 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 5.4 13/87] pinctrl: ralink: Check for null return of devm_kcalloc Date: Wed, 27 Jul 2022 18:10:06 +0200 Message-Id: <20220727161009.535088850@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161008.993711844@linuxfoundation.org> References: <20220727161008.993711844@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 0ba4e4e070a9..7cfbdfb10e23 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