mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Erick Karanja <karanja99erick@gmail.com>
To: gregkh@linuxfoundation.org, outreachy@lists.linux.dev
Cc: philipp.g.hortmann@gmail.com, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Erick Karanja <karanja99erick@gmail.com>
Subject: [PATCH 2/5] staging: rtl8723bs: replace kmalloc + memset with kzalloc
Date: Mon, 31 Mar 2025 18:37:55 +0300	[thread overview]
Message-ID: <d68a05a05966167f8e54f2fc779af2f1cfe32e07.1743434232.git.karanja99erick@gmail.com> (raw)
In-Reply-To: <cover.1743434232.git.karanja99erick@gmail.com>

Replace a call to kmalloc followed by memset with a single call to
kzalloc, which both allocates memory and zeroes it in one step.

This change improves readability and reduces redundant code.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/os_dep/osdep_service.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index a00f9f0c85c5..be46132a533a 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -24,12 +24,7 @@ void *_rtw_malloc(u32 sz)
 
 void *_rtw_zmalloc(u32 sz)
 {
-	void *pbuf = _rtw_malloc(sz);
-
-	if (pbuf)
-		memset(pbuf, 0, sz);
-
-	return pbuf;
+	return kzalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
 }
 
 inline struct sk_buff *_rtw_skb_alloc(u32 sz)
-- 
2.43.0


  parent reply	other threads:[~2025-03-31 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 15:37 [PATCH 0/5] Clean up patches for rtl8723bs driver Erick Karanja
2025-03-31 15:37 ` [PATCH 1/5] staging: rtl8723bs: use preferred comparison order Erick Karanja
2025-03-31 15:37 ` Erick Karanja [this message]
2025-03-31 19:05   ` [PATCH 2/5] staging: rtl8723bs: replace kmalloc + memset with kzalloc Julia Lawall
2025-03-31 15:37 ` [PATCH 3/5] staging: rtl8723bs: add spaces between ternary and binary operators Erick Karanja
2025-03-31 15:37 ` [PATCH 4/5] staging: rtl8723bs: no space before tabs Erick Karanja
2025-03-31 16:01   ` Julia Lawall
2025-03-31 15:37 ` [PATCH 5/5] staging: rtl8723bs: Rename variables Erick Karanja
2025-03-31 19:08   ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d68a05a05966167f8e54f2fc779af2f1cfe32e07.1743434232.git.karanja99erick@gmail.com \
    --to=karanja99erick@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=philipp.g.hortmann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®