From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 651C61714AC for ; Fri, 10 Jan 2025 05:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736487524; cv=none; b=ldkZrWbgfEEaxcJyOWx/6PJ0AsxMpMvAZ1n8uX1ETd5MRsD7DxQzEV1EezfTneGhTLWDmDjgKnddMNeNM6E8mH2RX3EOB0gruu1v16rwYZHEkP8a1KBZGJ7mgtNJcyDqYWdV7ncfCEvdWl0+GOiKYxWWkVM0uHjVtbNtq9c7Jes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736487524; c=relaxed/simple; bh=QTPUfbx6R77a/GvDZefKLFi+rweGMBAPjWz6xN4cIsI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lkf5ibKhTjWousS63frK/MPeXMPp+I8Q8bbTjATvAVkf//BsQ9F8i7CZvIQhOPNcQMWOpgrFLa/ijwed4gGgBKptye4/ormkFs0jtHDuAscQ/w+0dKxV+WO/x4MlSnewohE5GlR+GAo3FiApaSNobMklPaIwirVrI+QOFdzXw1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FPSq1yZC; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FPSq1yZC" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-385de59c1a0so896598f8f.2 for ; Thu, 09 Jan 2025 21:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736487520; x=1737092320; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3uVCnMYGVorPnWCZXIo6ZjHAAwok8CMs3XjG+q+NlDo=; b=FPSq1yZCqdLaXTEFbf/50YWHXaQH+RhEOPsY6BfLprK9t/DRH13GKhXFL9IQOfxJJu /2z6O+T+UQT2YER6ISNgKkzrvbPr+TiwZ8p0r445sLpTCZEceqXrAnMHC1yN+O7AIJAe 8dv6YP3xPKzztV5SFQ8ID5v9QQPp8jR+doyojwyVuhoER7KEOMQhlGsbT74ailuRdGMQ R2eaXq7UuI5R4h0d521qPERmv6c04wLMgUmH0T/JROKS3M4VeNb+VyfIW3wRoqb2DfPm cg6V1bxf/yXIUN5s4VCyvpf3suSQJ8lr7GrSm+bOE34nQ4tFjUTgvYte6MBKXOLgFHWo QCkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736487520; x=1737092320; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3uVCnMYGVorPnWCZXIo6ZjHAAwok8CMs3XjG+q+NlDo=; b=YfMBaalPFl7M/P1ShDfYhCQ1xxfu4vZsgwmYXAud69AONzrxr1lzawHT5+YQ5x7J2n fOJ7eBK/9etImwWJek0T0+reRbZkxVPh3pvT6QBIfQInz6brocm778GkJb8YXajP5F1M T0QGoJGLJnviksoEkIIoyLWB0YbByTBf4tbiOK2oV+cy1TBWCNgnrqSuEg1eN8LTv+Nb 6/HW6a70kyHYXg2TpbHn0dj3dQZeUv+PEh/8O6lb1mhn5EweiPZAQbcEYzGtQ993qB8W b/TUxqvxL4uKX/Gwt87HqUjPTUt//9boww+F4JesednZOBQo93WO8hTF2ThxZj7OvjAZ JJmw== X-Forwarded-Encrypted: i=1; AJvYcCXT6/shmk25kNUP1hHBF4+mxZ3vrV/7eRSrJBRtk9FJbV/sCMwPviD9iP1raVg+eqY6QtvoizhYzL0jvAk=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6fqZQp1lm9C14lUPo5wkbjriXtFBamudubhnrfDs8Jt7tdPhK T/tB96iucsiDEHPviu/66ORycbsoQfERlMGzc8FefKD0oTfJ4TBKqdGsw89AoCagQz7WapLrJhl 0 X-Gm-Gg: ASbGncto7bzZjwEwV4JEMR32TzxPftAqB9SnKyWqT/kaeoYI/Cb7KMtWf4xPjbMNEYN y/ZQycGbIkuVKkM7loBJxm740kSkcSjHulRDUnYp2IpV2zHsE4CrbQMwIOkBZ6dW1STUrWSwUT0 1egogLefb7eiMDEY5pThkEEq5rv9oFemjhgr6H3PiId2FuhJRJ1Dj2llEPQXa89Ty8UaFlzdPpo aU+HxtGwqDG/3ci+VL6pif4nrjhVX7z155NRfH5PofQa/VWYlQ0IPp8ja0ygQ== X-Google-Smtp-Source: AGHT+IGhGi4KgPhrmUw0YIvfY6S58SuiyhRszWUA9YtRmO/fw4AOAqGbt5FVpwm8S8bEzz5woqZjDw== X-Received: by 2002:a05:6000:1884:b0:385:e1e8:40db with SMTP id ffacd0b85a97d-38a8730a618mr7312117f8f.24.1736487519643; Thu, 09 Jan 2025 21:38:39 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b81b1sm3581323f8f.66.2025.01.09.21.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 21:38:39 -0800 (PST) Date: Fri, 10 Jan 2025 08:38:35 +0300 From: Dan Carpenter To: Costa Shulyupin Cc: Steven Rostedt , Daniel Bristot de Oliveira , John Kacur , "Luis Claudio R. Goncalves" , Eder Zulian , Tomas Glozar , Gabriele Monaco , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] rtla: Fix implicit NULL dereference Message-ID: <16990bcc-c328-457b-a789-0f318d8eaf3f@stanley.mountain> References: <20250109211358.2619367-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250109211358.2619367-1-costa.shul@redhat.com> The subject is bad because it says "Fix" when this is a clean up and it says "NULL dereference" when there isn't any NULL dereference. On Thu, Jan 09, 2025 at 11:13:26PM +0200, Costa Shulyupin wrote: > The `record` variable is NULL when tracing is not requested: > > struct osnoise_tool *record = NULL; > > if (params->trace_output) { > record = osnoise_init_trace_tool("osnoise"); > .... > > Value of `&record->trace` in this case is NULL just because > the `trace` member is the first member `struct osnoise_tool` with offset 0. > `&record->trace` just returns the offset. > > Explicit dereference `record->trace' would cause segmentation fault. > > Add explicit check for zero `record`. > This commit message is very confusing. I would normally not send a patch like this, but if I did send it the commit message would say something like: The "record" pointer can be NULL in this code. When we're calling trace_is_off(&tool->trace, &record->trace) and "record" is NULL then it kind of looks like a NULL dereference. It turns out that it's fine when you look at it more closely, but at first glance it looks sketchy. Add an explicit NULL check to make the code more clear. Tracing code is generally fast path code so maybe we don't want to add a NULL check? If we were really bothered by the existing code then a better fix would be to add an inline function to do it. regards, dan carpenter