From patchwork Sun Sep 24 06:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 726321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DFF8CE7A8A for ; Sun, 24 Sep 2023 06:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjIXG6F (ORCPT ); Sun, 24 Sep 2023 02:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjIXG6E (ORCPT ); Sun, 24 Sep 2023 02:58:04 -0400 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24813CE for ; Sat, 23 Sep 2023 23:57:56 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id kJ3wqxINJLxWbkJ3wqOyHA; Sun, 24 Sep 2023 08:57:54 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695538674; bh=iGzNAoRtFRkqcxCkNp3FPfcx3BcBPyiwFBXbBlaScV0=; h=From:To:Cc:Subject:Date; b=V0YCvZ/4caGOUQtjOU3zWtUT88aXF7bmdwDxpABBjf4ve4CqKUlQ6Yc7U5SMm605b OWvAUZCTR38E+8gZfqXbtA/4TvjqLgJF+79sjdQkLWnwjt5GK4pNVSkI7xx5l2oy5p bj3nt36Oaxt6AYlfbOSV8/HPT0V1H9CuBVo8E+QnuKmwQdq1X/kgbT8vQu80vQH8h7 hjlL5CZoKQGpQQFZP2sUszk2t36T+UGpHjNKWWMma6AZeQWr88lWf+kJOEhvYa8uex X6VePt6pTff6/pC9IVrm9TxvRStQV6ldj4rb+gDZXcH4bmiGtc44RzLdrIlFb+cPSt xxo4w/8Ie3Viw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 24 Sep 2023 08:57:54 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Kalle Valo , Christophe JAILLET Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH wireless 1/2] ath: dfs_pattern_detector: Fix a memory initialization issue Date: Sun, 24 Sep 2023 08:57:49 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If an error occurs and channel_detector_exit() is called, it relies on entries of the 'detectors' array to be NULL. Otherwise, it may access to un-initialized memory. Fix it and initialize the memory, as what was done before the commit in Fixes. Fixes: a063b650ce5d ("ath: dfs_pattern_detector: Avoid open coded arithmetic in memory allocation") Signed-off-by: Christophe JAILLET Reviewed-by: Jeff Johnson --- Patch #1/2 is a fix, for for wireless. Patch #2/2 is for wireless-next I guess, but depnds on #1 Not sure if we can mix different target in the same serie. Let me know. BTW, sorry for messing up things with a063b650ce5d :( --- drivers/net/wireless/ath/dfs_pattern_detector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/dfs_pattern_detector.c b/drivers/net/wireless/ath/dfs_pattern_detector.c index 27f4d74a41c8..2788a1b06c17 100644 --- a/drivers/net/wireless/ath/dfs_pattern_detector.c +++ b/drivers/net/wireless/ath/dfs_pattern_detector.c @@ -206,7 +206,7 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq) INIT_LIST_HEAD(&cd->head); cd->freq = freq; - cd->detectors = kmalloc_array(dpd->num_radar_types, + cd->detectors = kcalloc(dpd->num_radar_types, sizeof(*cd->detectors), GFP_ATOMIC); if (cd->detectors == NULL) goto fail;