linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li zeming <zeming@nfschina.com>
To: James.Bottomley@HansenPartnership.com, deller@gmx.de
Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Li zeming <zeming@nfschina.com>
Subject: [PATCH] parisc: Increase the usage check of kmalloc allocated object a
Date: Wed, 14 Sep 2022 14:04:28 +0800	[thread overview]
Message-ID: <20220914060428.4039-1-zeming@nfschina.com> (raw)

In the case of memory allocation failure, no alignment operation is
required.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 drivers/parisc/iosapic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 3a8c98615634..33de438916d3 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -229,7 +229,9 @@ static struct irt_entry *iosapic_alloc_irt(int num_entries)
 	 * 4-byte alignment on 32-bit kernels
 	 */
 	a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL);
-	a = (a + 7UL) & ~7UL;
+	if (a)
+		a = (a + 7UL) & ~7UL;
+
 	return (struct irt_entry *)a;
 }
 
-- 
2.18.2


             reply	other threads:[~2022-09-14  6:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  6:04 Li zeming [this message]
2022-09-14  6:18 ` [PATCH] parisc: Increase the usage check of kmalloc allocated object a Helge Deller
2022-09-14  6:43   ` Rolf Eike Beer
2022-09-14  9:04     ` Helge Deller
2022-09-14 14:25       ` Rolf Eike Beer
2022-09-15  5:44         ` Helge Deller

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=20220914060428.4039-1-zeming@nfschina.com \
    --to=zeming@nfschina.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).