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 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D693BC65BAE for ; Thu, 13 Dec 2018 05:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9724220672 for ; Thu, 13 Dec 2018 05:07:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9724220672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbeLMFHp (ORCPT ); Thu, 13 Dec 2018 00:07:45 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:30809 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726226AbeLMFHp (ORCPT ); Thu, 13 Dec 2018 00:07:45 -0500 Date: 13 Dec 2018 14:07:42 +0900 X-IronPort-AV: E=Sophos;i="5.56,347,1539615600"; d="scan'208";a="2698575" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 13 Dec 2018 14:07:42 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8210942C4F82; Thu, 13 Dec 2018 14:07:42 +0900 (JST) Message-ID: <87y38u10rx.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Nathan Chancellor Cc: Mark Brown , Liam Girdwood , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ASoC: simple-card: Dereference pointer for memcpy sizeof in asoc_simple_card_probe In-Reply-To: <20181213043548.29747-1-natechancellor@gmail.com> References: <20181213043548.29747-1-natechancellor@gmail.com> User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nathan > sound/soc/generic/simple-card.c:462:6: warning: argument to 'sizeof' in > 'memcpy' call is the same pointer type 'struct asoc_simple_dai *' as the > source; expected 'struct asoc_simple_dai' or an explicit length > [-Wsizeof-pointer-memaccess] > sizeof(priv->dai_props->cpu_dai)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > sound/soc/generic/simple-card.c:464:6: warning: argument to 'sizeof' in > 'memcpy' call is the same pointer type 'struct asoc_simple_dai *' as the > source; expected 'struct asoc_simple_dai' or an explicit length > [-Wsizeof-pointer-memaccess] > sizeof(priv->dai_props->codec_dai)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 2 warnings generated. > > Commit 4fb7f4df49d3 ("ASoC: simple-card: use cpu/codec pointer on > simple_dai_props") updated {cpu,codec}_dai to be pointers in struct > simple_dai_props but didn't update these locations to dereference the > pointers to get the proper size of their contents. > > Signed-off-by: Nathan Chancellor > --- > sound/soc/generic/simple-card.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c > index 766123485d7c..d4738d3eb2f1 100644 > --- a/sound/soc/generic/simple-card.c > +++ b/sound/soc/generic/simple-card.c > @@ -459,9 +459,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) > dai_link->dai_fmt = cinfo->daifmt; > dai_link->init = asoc_simple_card_dai_init; > memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai, > - sizeof(priv->dai_props->cpu_dai)); > + sizeof(*priv->dai_props->cpu_dai)); > memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai, > - sizeof(priv->dai_props->codec_dai)); > + sizeof(*priv->dai_props->codec_dai)); > } Ahh.. yes, simple-card is supporting non DT case, too. Thank you for your patch. But, I think "&priv->dai_props->codec_dai" need to fix, too. And it needs to point cpu_dai/codec_dai. Thank you for pointing it. I will fixup and post with your name. Best regards --- Kuninori Morimoto