From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752013AbdJETaV (ORCPT ); Thu, 5 Oct 2017 15:30:21 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:47037 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbdJETaT (ORCPT ); Thu, 5 Oct 2017 15:30:19 -0400 X-Google-Smtp-Source: AOwi7QDlM25XeK+tJYUVOZH6hbuUr4Ea4BBhe++Dfg2EetkYwOYIAtw2IrK9UpRBjhT8hInMEIvXPw== Date: Thu, 5 Oct 2017 12:30:17 -0700 From: Kees Cook To: Paul Bolle Cc: Karsten Keil , "David S. Miller" , Johan Hovold , linux-kernel@vger.kernel.org, gigaset307x-common@lists.sourceforge.net, netdev@vger.kernel.org Subject: [PATCH] isdn/gigaset: Use kzalloc instead of open-coded field zeroing Message-ID: <20171005193017.GA105834@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This replaces a kmalloc followed by a bunch of per-field zeroing with a single kzalloc call, reducing the lines of code. Cc: Paul Bolle Cc: Karsten Keil Cc: "David S. Miller" Cc: Johan Hovold Cc: gigaset307x-common@lists.sourceforge.net Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/isdn/gigaset/bas-gigaset.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 2da3ff650e1d..33151f05e744 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c @@ -2200,7 +2200,7 @@ static int gigaset_initcshw(struct cardstate *cs) { struct bas_cardstate *ucs; - cs->hw.bas = ucs = kmalloc(sizeof *ucs, GFP_KERNEL); + cs->hw.bas = ucs = kzalloc(sizeof(*ucs), GFP_KERNEL); if (!ucs) { pr_err("out of memory\n"); return -ENOMEM; @@ -2212,15 +2212,7 @@ static int gigaset_initcshw(struct cardstate *cs) return -ENOMEM; } - ucs->urb_cmd_in = NULL; - ucs->urb_cmd_out = NULL; - ucs->rcvbuf = NULL; - ucs->rcvbuf_size = 0; - spin_lock_init(&ucs->lock); - ucs->pending = 0; - - ucs->basstate = 0; setup_timer(&ucs->timer_ctrl, req_timeout, (unsigned long) cs); setup_timer(&ucs->timer_atrdy, atrdy_timeout, (unsigned long) cs); setup_timer(&ucs->timer_cmd_in, cmd_in_timeout, (unsigned long) cs); -- 2.7.4 -- Kees Cook Pixel Security