Received: by 10.192.165.148 with SMTP id m20csp5131449imm; Tue, 8 May 2018 23:06:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoVHhx1YraRiaSADaaqccRLAH659di2dmHzYM8ANUhQiiC+b6D9SqXfMHJBHJR2hOojqsrn X-Received: by 2002:a17:902:b286:: with SMTP id u6-v6mr44608117plr.68.1525846011200; Tue, 08 May 2018 23:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525846011; cv=none; d=google.com; s=arc-20160816; b=n//i8GEw70OJo+f76nsCbooEG7jjr6lUwpLeFZYC4OQwKjxlEPo+3oE/FZupRRgb3z boQ0zSD8zFsjHA54YKUY3xk8ybhV1XKsu7h60dIyPA/ZVRTA1nIc2si+7p47iwUL/wIS w6eKC35mOTulA9qkfVLuvuhP8r8IBozDD9QMiFwoHkif7EaH3VU/xHZ1zo+yrldDEDOv jwUJ3Im0J1HY78Z9HWk87Jpyzsyy0nwOPFC/15sFkvU8xB/cI4vOUzs9s8P5BTsyEKGZ JWKj/bVLSS00R0wh3KMuvIX9wBDZYb2Qm0bt1Mgps6V6OQJFkOPuAfeIJ+lePtlwXGZp FogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=amRFn+xf8OhHynEcDo3FzaSsiXMpGnRuZKs9NmcT600=; b=UcALIGI/fkBng/pMbDtOiNAWB5ZVm4JiCVLJ5HLce+6ELoKTh8rIih3JhhwtAavduQ 7x4kZGk/DleFDx1TY7xYA66i6wEnzt3KtLbBJiHbqR/YXFCNiz8IV6jwayZVt1uz+wVh Yv9++rWrDYAe9yBHsadu5DpwbXqYvZjHwO5fE+e1uqpMrqgpUGZ/zMe8wNA4WvI8k4oH syPAHTAgyXj7SviezUS2JlUxA18zvB1tSgfWHUzMc8KomPRsia2Tir6Gwu9KI8aVQV9Q +6JEigv9/LNnDxcBdLD/YXeI4/ke+S+L2dNkbZBzuBIvKXis7Npa7qaWIOPqrafaNyjb EwPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VnmE/cyC; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b190-v6si12779302pgc.18.2018.05.08.23.06.36; Tue, 08 May 2018 23:06:51 -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=@linaro.org header.s=google header.b=VnmE/cyC; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756153AbeEIGGK (ORCPT + 99 others); Wed, 9 May 2018 02:06:10 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:39099 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756135AbeEIGGH (ORCPT ); Wed, 9 May 2018 02:06:07 -0400 Received: by mail-wm0-f48.google.com with SMTP id f8-v6so25354302wmc.4 for ; Tue, 08 May 2018 23:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=amRFn+xf8OhHynEcDo3FzaSsiXMpGnRuZKs9NmcT600=; b=VnmE/cyCf2f62NayQ1Jfxvqhu9VnwMhO1L0FUO3mOJb3wKqaiWm6suxO6Y2K13sCew Lg+BJ9PRHyFYhQa22aAvd5ue5PQxa0SyBhtHwz/AwYzZKxYGA7HqM5cijMiB+Gcqn3qn EJRC1hNRSuBS2nQMs2E00eNsGkB+t6wC/vhto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=amRFn+xf8OhHynEcDo3FzaSsiXMpGnRuZKs9NmcT600=; b=h9j1pYLO+lKZDTyQcE5RiYbt44OD5jyVDj5uu0vxjJlCJEcaXCiVidzLWrKZhzVNWJ VWyP3PhUqS1sVGRuftYxRD193pREXQDgbsgXOMHmRfmhVappgwL4jl3ihAmnCp+h14L/ dDa4cLPyLKqCSWySC7Wllvz/F/rPB3KcVZuaZiqBfneYLddlHsDKzgcX0XSGocK6fHq+ q0hSSk8e2rCTpxaVB+pzsXTxn9WFu1S5Iwbf/dCLJM5Gt7kNsGYjn0tXAnACjga+Adnh xSYSwknxloC5YN7dtVj/p31V3H9oYlJPV816RQgyw2mpqzdYNn6fCAxH/AlAYpsF9Q2J JDYg== X-Gm-Message-State: ALQs6tB6Fe/VPre8ndGE0DNdjANBbZAjN1DAZx1KlETaxT7DQ2FuSedM icOu0qpijiHYQ2kIwuXNVne4IQ== X-Received: by 2002:a50:a550:: with SMTP id z16-v6mr58314531edb.103.1525845966609; Tue, 08 May 2018 23:06:06 -0700 (PDT) Received: from [192.168.0.18] (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.googlemail.com with ESMTPSA id d8-v6sm6701502edk.50.2018.05.08.23.06.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 23:06:06 -0700 (PDT) Subject: Re: [PATCH v7 08/24] ASoC: qdsp6: q6core: Add q6core driver To: Banajit Goswami , andy.gross@linaro.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org Cc: gregkh@linuxfoundation.org, david.brown@linaro.org, mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org, tiwai@suse.com, perex@perex.cz, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com, spatakok@qti.qualcomm.com References: <20180501120820.11016-1-srinivas.kandagatla@linaro.org> <20180501120820.11016-9-srinivas.kandagatla@linaro.org> <46511158-ed1d-7f07-0a8f-b325c088e386@codeaurora.org> From: Srinivas Kandagatla Message-ID: <9ea47387-d849-19e8-1075-74a5e7e11a22@linaro.org> Date: Wed, 9 May 2018 07:06:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <46511158-ed1d-7f07-0a8f-b325c088e386@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Banajit for the review! On 04/05/18 20:04, Banajit Goswami wrote: >> + >> +static int q6core_callback(struct apr_device *adev, struct >> apr_resp_pkt *data) >> +{ >> + struct q6core *core = dev_get_drvdata(&adev->dev); >> + struct aprv2_ibasic_rsp_result_t *result; >> + struct apr_hdr *hdr = &data->hdr; >> + >> + result = data->payload; >> + switch (hdr->opcode) { >> + case APR_BASIC_RSP_RESULT:{ >> + result = data->payload; >> + switch (result->opcode) { >> + case AVCS_GET_VERSIONS: >> + if (result->status == ADSP_EUNSUPPORTED) >> + core->get_version_supported = false; >> + core->resp_received = true; >> + break; >> + case AVCS_CMD_GET_FWK_VERSION: >> + if (result->status == ADSP_EUNSUPPORTED) >> + core->fwk_version_supported = false; >> + core->resp_received = true; >> + break; >> + case AVCS_CMD_ADSP_EVENT_GET_STATE: >> + if (result->status == ADSP_EUNSUPPORTED) >> + core->get_state_supported = false; >> + core->resp_received = true; >> + break; >> + } >> + break; >> + } >> + case AVCS_CMDRSP_GET_FWK_VERSION: { >> + struct avcs_cmdrsp_get_fwk_version *fwk; >> + int bytes; >> + >> + fwk = data->payload; >> + core->fwk_version_supported = true; >> + bytes = sizeof(*fwk) + fwk->num_services * >> + sizeof(fwk->svc_api_info[0]); >> + >> + core->fwk_version = kzalloc(bytes, GFP_ATOMIC); >> + if (!core->fwk_version) >> + return -ENOMEM; > When the above allocation fails, core->fwk_version_supported will be > still true, and q6core_get_fwk_versions() will return 0 (timeout as > core->resp_received will not be set to true). This can cause a NULL > pointer dereference inside the if() loop pointed below (added comment). > Please move the line to set core->fwk_version_supported flag to after > memset() to copy fwk version info. Yes, makes sense, I fixed this and other comments in v8. thanks, srini >> + >> + memcpy(core->fwk_version, data->payload, bytes); >> + >> + core->resp_received = true; >> + >> + break; >> + } >> + case AVCS_GET_VERSIONS_RSP: { >> + struct avcs_cmdrsp_get_version *v; >> + int len; >> + >> + v = data->payload; >> + core->get_version_supported = true; >> +