From patchwork Tue Oct 17 00:29:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 826665 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Sxp4wTKV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGGqY4VDWz9sP1 for ; Tue, 17 Oct 2017 11:52:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757129AbdJQAr1 (ORCPT ); Mon, 16 Oct 2017 20:47:27 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:52342 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752274AbdJQAr0 (ORCPT ); Mon, 16 Oct 2017 20:47:26 -0400 Received: by mail-pg0-f47.google.com with SMTP id a192so67413pge.9 for ; Mon, 16 Oct 2017 17:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OVmzjTc+goNu3CQcWkNMiv35oyikbTz2DJ3SrFzlw54=; b=Sxp4wTKVkbk/BSSEVJ0qOGGvLN+qklwrwjraZlx1NzXbQTn1uKYEtgVZj0fBWnM4kj Ci+6hM3AH4/rA86e1oI9z03tdJg5FFY1XMz5qMpCS+OiRdV60g45D82ryvJw1aQx8u8w CxqQidhfBPbX2NrnoevlUg+9EbBExP+/5zV50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OVmzjTc+goNu3CQcWkNMiv35oyikbTz2DJ3SrFzlw54=; b=dED2FW4RaZgD0wlX1whweMNzA1npqCBEZ3iYh2S1bT0dJ2IofAtVG9524eEfA35nHH b3VmABXCR46gRfmpOYMzKrmX2MFIMpSAdn4fe4YAjoraKIw3vFCKm7AICGZg1pZq0CR6 /NyBJPF083c7YPLiDtNu2Y+4TM0MUJmi1/pd3iSPyRXK2vv28UVhBiW695jRy0V2m1aM 02eeE/gNMus+kXZ+vZlPj2UzHt+x7xutj5sI1BsR8FaGbUWxTXdwKtDaO6Pn9Q84yZBp d8QyjXTKzhXDbMSqb0uC0j9i7U0AQG949mqI7uuwuYay2Czbsl3LfhvR+bP1YBi+iHOD FxxA== X-Gm-Message-State: AMCzsaUiXzSuAFqJJFldmnGNPFGCv7OyLCw0RtrKosX7V6378x9Pow1M L3nL0YADU/w/JMLCVVPYQPPDtw== X-Google-Smtp-Source: AOwi7QCZhuSu1ERTJ4mOUc4cxWmE5tav/ZPIW2EEyqg+kyVJeIbwNd6dz3aldpwmyfZIY0hjeLVIbA== X-Received: by 10.99.124.91 with SMTP id l27mr9631310pgn.49.1508201245667; Mon, 16 Oct 2017 17:47:25 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id n72sm8033013pfi.92.2017.10.16.17.47.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:47:24 -0700 (PDT) From: Kees Cook To: "David S. Miller" Cc: Kees Cook , Paul Bolle , Karsten Keil , Johan Hovold , gigaset307x-common@lists.sourceforge.net, netdev@vger.kernel.org, Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH 31/58] isdn/gigaset: Use kzalloc instead of open-coded field zeroing Date: Mon, 16 Oct 2017 17:29:15 -0700 Message-Id: <1508200182-104605-32-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508200182-104605-1-git-send-email-keescook@chromium.org> References: <1508200182-104605-1-git-send-email-keescook@chromium.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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 Acked-by: Paul Bolle --- 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);