From mboxrd@z Thu Jan 1 00:00:00 1970 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 44E35ECAAD3 for ; Wed, 14 Sep 2022 06:05:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbiINGE7 (ORCPT ); Wed, 14 Sep 2022 02:04:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiINGEy (ORCPT ); Wed, 14 Sep 2022 02:04:54 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F13BB87F; Tue, 13 Sep 2022 23:04:47 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 8D8F61E80D5E; Wed, 14 Sep 2022 14:02:31 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OSC8BRoRCd7h; Wed, 14 Sep 2022 14:02:28 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id BAA481E80D58; Wed, 14 Sep 2022 14:02:28 +0800 (CST) From: Li zeming To: James.Bottomley@HansenPartnership.com, deller@gmx.de Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] parisc: Increase the usage check of kmalloc allocated object a Date: Wed, 14 Sep 2022 14:04:28 +0800 Message-Id: <20220914060428.4039-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org In the case of memory allocation failure, no alignment operation is required. Signed-off-by: Li zeming --- 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