Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5732169ybi; Tue, 28 May 2019 18:54:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVkZ17AdDiDqD91Fd8t4wJ4U/OPjUK7OFDSisE9MYyhbogQEI3dNfN1xb6tc7kLOq3TgXJ X-Received: by 2002:a17:902:934b:: with SMTP id g11mr33803942plp.289.1559094895934; Tue, 28 May 2019 18:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559094895; cv=none; d=google.com; s=arc-20160816; b=KaY2Vn6Q3g5gwhDJo3gSrBuEPZHGsXJ4zfDP4c+QeNPxcYpM8jkneHruC7E6HZil00 tda8mA9hr7jl4eDPGjKBOnoKI2DzsDfvO34mbf/UWFbv3CZydeh/0vm0RA5ffJrUdez5 lBfjrFTBlkz4QIx4Sk3kdxZwbqX8KeU22kjZg8rqaxtoiMbvWwaIL2BjJy5JywvX0OUa h8c1LGtxMP2xr9T3rU8M6/QEcUv7Tk1hYSLpyt6DiDJi6PnT3KJpvG4jgyDDR/I9UciP bjSgPjyAu3VNTl2FWRFnM2/g7kNPjucw6KT7pp7VieQr8c6Vlr0IpcILF9U/wwXN+6rY su1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=GFkfdKcziRNK4G5X1v4GEXAK4KAxWzSyd1rG3iBhpqE=; b=TCyzyhQMtMYBxHziSw6rMXUsMwxO2BQlglf7+r625WXuvwCOLAHZCI4QQexTtLYCIF XDE83sp3Sp1kJ9WjOI06AQtVa5CDUCc+hSPSn5JNotg+Hu0Z2oH1Bplt86S1UGI6yXXR skCYjXhxc+uJPfa46laV4ChVeC/bMvfkoAnR9Vt2GcjZvOXMXgkBQoqVnWUW6Tyq+e9o vXVkUC2R0MXn7EGpFqPjq05Vrq/iTm+0sU9V198KJNhv7cL0HGcSBVhycqHixw2vpDUE XXm7kHMx8BSgWXGcI1V9rbDvLSqkGVFcDF93WDO9W8cyndgjeCPHon7mgdo2jvoApBh8 RQSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gf6uf9ZL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m32si23447030pld.365.2019.05.28.18.54.39; Tue, 28 May 2019 18:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gf6uf9ZL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbfE2Bxa (ORCPT + 99 others); Tue, 28 May 2019 21:53:30 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41563 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbfE2Bxa (ORCPT ); Tue, 28 May 2019 21:53:30 -0400 Received: by mail-pg1-f195.google.com with SMTP id z3so326099pgp.8 for ; Tue, 28 May 2019 18:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=GFkfdKcziRNK4G5X1v4GEXAK4KAxWzSyd1rG3iBhpqE=; b=Gf6uf9ZLJFdbF2Tz3CtbEi5DpT7zoLEJswQZZlqfv62FlIUi96M62iFykxyCx2RZYV C0EWTeRU33+5d03Ow2UeCv+x6g5nqmfFFS8E4ckBgSCnFQSrOu4oHjZQGBLMHlRlk/a0 xyKzPWHOb8+JXHFfNlpn7S5d70/n4j7ErVcoEuG8pyhICJeF1h7X8ynUwqEOgwNh/+4a Wq7GggU3PYOAGWpkYx1bMMRvOAEqjCsY6JuY5zzUnCT1lwpm1+Y3zO1ABgcRm5TxbVBy cKPdLbJvHwqb9VyIaVRYrS7ELRu2uxeerFeta0Mb/Mv76DWFRngOse4aSm1ZjdCgnHMW fhjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=GFkfdKcziRNK4G5X1v4GEXAK4KAxWzSyd1rG3iBhpqE=; b=ItGAx5p8grc1lOTGl1hbr0A10q1VC0Kn81y5Lu1EuR8He0kGZ7DtOTjCNKPdCfn0Dg EAM1EP2G/9K6W3DqUcLDbY15iQ4KVg0uvy9r9Fj+gwnm+Y+DV94rrwgoHdN84X0tJ90R 6rRcumW5LXmg9jriqmigDztmget7v7vzCQ19zWmglSIJUGPLWndY6JypVqDbCPCrGXsz XYgE4o9F1AzOdndSBuxS5sERhipZgjFjPnBmqfBm9UcTGXfh41dX08U/9phP5ksM2LmX mI2++TkL7rHoKhtyomi8+zE9ZI5YANCyu4j6mloCv3ek+9kVMJ5XCH72A5suwbL+Hupz 9MyQ== X-Gm-Message-State: APjAAAUqNyXfFuXxXp/Eqt/pXkFPaD4SHVkvzzyQvVry4JU8x1CDnTbd eJ0o6cK99l3MTp7lBjwgSCI= X-Received: by 2002:a17:90a:35c1:: with SMTP id r59mr2222430pjb.49.1559094809768; Tue, 28 May 2019 18:53:29 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id l13sm3654097pjq.20.2019.05.28.18.53.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 18:53:28 -0700 (PDT) Date: Wed, 29 May 2019 09:53:05 +0800 From: Gen Zhang To: broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz, wen.yang99@zte.com.cn Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] wcd9335: fix a incorrect use of kstrndup() Message-ID: <20190529015305.GA4700@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In wcd9335_codec_enable_dec(), 'widget_name' is allocated by kstrndup(). However, according to doc: "Note: Use kmemdup_nul() instead if the size is known exactly." So we should use kmemdup_nul() here instead of kstrndup(). Signed-off-by: Gen Zhang --- diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index a04a7ce..85737fe 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -2734,7 +2734,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, char *dec; u8 hpf_coff_freq; - widget_name = kstrndup(w->name, 15, GFP_KERNEL); + widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; ---