Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp988756lqb; Sat, 25 May 2024 00:32:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAcgKuQjPjVRE48A2rl87RD7wI2s2bqpXQyEgE+obx0d0QHkGOmlLkwva65VQbkDK/kmK3J0IgUGabDxjMrvjZBnxPj2IHez6LDgqTgg== X-Google-Smtp-Source: AGHT+IGOHdthGzHHeZwxfDW3Vn6A1LqBjohxe9MX+kHtIRxuAGHZr+k3P5pwpfZq1aRbp37DlJ8E X-Received: by 2002:aca:b04:0:b0:3c9:32e6:7e1e with SMTP id 5614622812f47-3d1a7b30870mr4149938b6e.50.1716622363410; Sat, 25 May 2024 00:32:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716622363; cv=pass; d=google.com; s=arc-20160816; b=MWRB9DWw4E+pWiZ3BB4H7brEkOdbkBOIp+QdKz7toXLm37Cx334rIH0xXgGevAUauy Lf1LPEmk4Jt7u1zRBbB54kNjPVJKwk9/jigx5q63Yj8zRTqsovnfyGbnpRPSvxPq3SbW muVIW7S+fw9YmWyVkYSNQvCD4cvDoX9xk2VJvkr6VLqDtnPw0WxYl7BQb90No4vJ3gpo OvdibHy0PplS+xy+YzY8C5d4WzluFQ6LldzyEElLBZnmVh0x7DFgli5t6AcOhkCXmXGT 4V2DPqpw6H4gysF7vG3q1Y+4VsLNYjj6JrX2yhF3P8tDvQLQKKtTPYY21diI4zXecJNx hXEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :dkim-signature:dkim-signature:from; bh=wi+/J+ptePQGvzXQ0v1rtPKu00m6VIgRcYRhLkIVOyY=; fh=XXx8+z4ltyH//32v+8zsqZ5wAy4Nt6cXD8Yf+W2/eXk=; b=nWKSRdLrtm0rxcKMFPt310p0SRXhfbIJakDYBLL+DargKktPNVb/d7KChwfPsnq7mt u5MeE5ZAA1c74Jc7EDcesJbKEiXgXB455x9CEcoOximu9G3Br72wSt7r8EKg+NzCt7XG 88FdtULdEBkaf6mhb297gRSgMpjrw30tdFd0nh+EM8xkU7i12UNNYQWdiTn8x6SdO5Y1 GhRXmp67inFqGHib1ZoldZDQczsg/qqgAhFAxlpR7gzUmEkGbjs7dE8v0JreEKtkyCVi VgFW1G8lmmlKLzsw9m4I65PWv3/nCWScuXURslpDvIE+GpOnKiI7jIbxaA5F20ggy8yp Wm/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YcUDsL6D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-189302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac06f50be8si33861966d6.45.2024.05.25.00.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 00:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YcUDsL6D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-189302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1473C1C20E0B for ; Sat, 25 May 2024 07:32:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E6AB101F4; Sat, 25 May 2024 07:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YcUDsL6D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HDbMBRb+" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 527D2DDC4 for ; Sat, 25 May 2024 07:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716622357; cv=none; b=nHo4iIVUxNMMHcEFCHhZs6U/JCI1TeAQudnPvOXT1V+a/J52Q+r9VkV2C4h0LC4uIZm+6knWiaP6ay/hbq5jSX3YHEq7NkvIkBISHmwNyLqlxDh+0BjrYynsZ/yv9psKrlMxZW8Lje8DCjEwYvaOnCGj5KICC2lWJjXWEBv5ykQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716622357; c=relaxed/simple; bh=7/qtvsoEYPm/gp5Dn4A9Wd7Ix2aEqp7UV1ynS6s6QVg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=HO3CH4REf2Z0T31jArR055maHzq3CtXKlIjrPKOZhwgmpkfAN54vjlSF6NJfF2jjtDbawPLlvo2YzwFtdprKU2Q+HjMjDsk0uk0jUxLBhqWjulsOST4iI/i6jTsBIOXh4pdT6Pyah3VDW3BWsWHvr8lPNGVkjk0lUpt6wAYWx4k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YcUDsL6D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HDbMBRb+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716622353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=wi+/J+ptePQGvzXQ0v1rtPKu00m6VIgRcYRhLkIVOyY=; b=YcUDsL6DOKRV1Su0hk7BeA3Umye3dohePC6fFISxBMs9/b/VWwCI6EN8n93rcMvsjw5Mz4 SurM6A2oipPlgllcdUWCQ3bkCsapnX2nvA5Jp/Wa80pNASPt4xRUy7rxPpsvSinl6fQcJ7 Ih3uKtg3W6HCdFgsxmNuCD+2rgCpwMvnI9CgqMjnoU2mTjB4gLKkJ0rSvSDzJfX4jQ4yRu 6QBSQDf/SU7ISC7GAUCRdQuIIe35Rr7f+/cIOF8ovWDJf6CSJf1WYInIt5tc3aQ0Tel8Vd oHHk5XFiAhCP3OiORvHNfE5DfAEQKqbHSTqSFaKpyLSyPDPyKubIJxyHpjzH6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716622353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=wi+/J+ptePQGvzXQ0v1rtPKu00m6VIgRcYRhLkIVOyY=; b=HDbMBRb+gwwDSymD2ZGCQydsOKGCm/du827Due4IKaY5lYB04uZwONAawKs+PPdhghdJz5 eA+t0v+xyKtonjCw== To: Larry Finger , Florian Schilhabel , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Nikita Zhandarovich Cc: Nam Cao , syzbot+83763e624cfec6b462cb@syzkaller.appspotmail.com Subject: [PATCH] staging: rtl8712: remove unnecessary alignment of pxmitpriv->pxmitbuf Date: Sat, 25 May 2024 09:32:29 +0200 Message-Id: <20240525073229.4144612-1-namcao@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This driver wants pxmitpriv->pxmitbuf to be 4-byte aligned. This is ensured by allocating 4 more bytes than required with kmalloc(), then do the p = p + 4 - (p & 3) trick to make sure the pointer is 4-byte aligned. This is unnecessary. Pointers from kmalloc() are already at least 8-byte-aligned. Remove this alignment trick to simplify the code, and also to stop wasting 4 extra bytes of dynamic memory allocator. This also gets rid of a (false) warning from kmemleak. This 4-byte-aligned buffer is used to store pointers from kmalloc(). For 64-bit platforms, pointer size is 8 bytes and kmemleak only scans for pointers in 8-byte blocks, thus it misses the pointers stored in this 4-byte-aligned buffer and thinks that these pointers have been leaked. This is just a false warning, not a real problem. But still, it would be nice to get rid of these warnings. Reported-and-tested-by: syzbot+83763e624cfec6b462cb@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-staging/000000000000809328060a8a4c1c@google.com Signed-off-by: Nam Cao --- Patch sent using this driver with this patch applied. drivers/staging/rtl8712/rtl871x_xmit.c | 13 +++++-------- drivers/staging/rtl8712/rtl871x_xmit.h | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 6353dbe554d3..408616e9afcf 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -117,12 +117,9 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, /*init xmit_buf*/ _init_queue(&pxmitpriv->free_xmitbuf_queue); _init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = - kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, GFP_ATOMIC); - if (!pxmitpriv->pallocated_xmitbuf) + pxmitpriv->pxmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf), GFP_ATOMIC); + if (!pxmitpriv->pxmitbuf) goto clean_up_frame_buf; - pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - - ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3); pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; for (i = 0; i < NR_XMITBUFF; i++) { INIT_LIST_HEAD(&pxmitbuf->list); @@ -165,8 +162,8 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, for (k = 0; k < 8; k++) /* delete xmit urb's */ usb_free_urb(pxmitbuf->pxmit_urb[k]); } - kfree(pxmitpriv->pallocated_xmitbuf); - pxmitpriv->pallocated_xmitbuf = NULL; + kfree(pxmitpriv->pxmitbuf); + pxmitpriv->pxmitbuf = NULL; clean_up_frame_buf: kfree(pxmitpriv->pallocated_frame_buf); pxmitpriv->pallocated_frame_buf = NULL; @@ -193,7 +190,7 @@ void _free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } kfree(pxmitpriv->pallocated_frame_buf); - kfree(pxmitpriv->pallocated_xmitbuf); + kfree(pxmitpriv->pxmitbuf); free_hwxmits(padapter); } diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index cdcbc87a3cad..784172c385e3 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -244,7 +244,6 @@ struct xmit_priv { int cmdseq; struct __queue free_xmitbuf_queue; struct __queue pending_xmitbuf_queue; - u8 *pallocated_xmitbuf; u8 *pxmitbuf; uint free_xmitbuf_cnt; }; -- 2.39.2