Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2938455lqt; Tue, 23 Apr 2024 06:22:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM/AIfxi/WmJ4AEmWuEyXO2hvrE66y6UOPbChVUIM/n4JugXrb25o7ESw7fKUbgpIOP/J4OCyCENuDfQCJFn80Dr3mmzj1CZQw4ZCMmQ== X-Google-Smtp-Source: AGHT+IE/Jb4quXsJhfdFT0ZZxs5Q6Sq9E0eRBn/KaPhrEe49RAh/i/61bvduPOA3NGntrEzdE5u2 X-Received: by 2002:a54:4686:0:b0:3c6:4c9:9888 with SMTP id k6-20020a544686000000b003c604c99888mr13028282oic.17.1713878561595; Tue, 23 Apr 2024 06:22:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713878561; cv=pass; d=google.com; s=arc-20160816; b=pcdJxchlIrQQdoJUl52Oj1N5N/9hHV8okItH58Xm8KF0qsOf/CN4CObnsKpglcOZPm yeN8ZHdQjMnxSpmXzVfqyVQ+6DemOrwx/Y9DtSCqfJyiL4nn77wImNwcjjKl80TXbPP8 yoc9E6XEZhNZBC4LP//Jd4mqMSl/RMEEnrJTlDJp5fYhtgTUpA+1IPOUhLqSasqMNzlk Naa43cGug0bWJgzX05hqr28wKsOQCVL0DhOk544aXn4Z7YPUme6eVPGMJaqGjXISqvpU HEpy0/Dk5W/CeC9Inh/uZ4SfvqYfc+ZEApcV18Anok6QKY65pkm2KNfU/aRV8vvd6nl7 Q6nw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1n7JSfYWxQy0YOfnlGRtbUocgojCIv1pFKvACUA3fEs=; fh=PVIkvvncV0/NfdzXDjLaTSkWU/9g6PXGTrXemJ+4OrE=; b=aUVE3cxQ612Xb/hTu1x1n/gtZFurdLaTn4WLDoASEjzQVxN2E+g7vJnaSVRfBaMco0 HjD0TkEY9+yVn1r8kRl0aPJlaOjG7v83gCaxc0piOs4viuKqrrp41cyrEBhQjv5itsqe PIGP9uLD+gcMCB3Svq9+YnfFr4TmncyzK4x5ZEGsVdImd3+QMwXsGIcJwQU/oV6P7g2v +qdEExH71GpQ3cY3zzpRwOdyWvMz4yynRt4M6JOKKgwc+nS0omAV/dIY+Wt3aqModGyG 8Jqo3So7a5koD6+DKVplIxeSVuDJKbViGvJddTTHAhqXCMmCglJUBFEwTNcmnI/Cno33 hUmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbPk0RTL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-155274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kk11-20020a056214508b00b0069b51b28a8esi12958336qvb.149.2024.04.23.06.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbPk0RTL; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-155274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 450B71C210F2 for ; Tue, 23 Apr 2024 13:22:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02EE513699C; Tue, 23 Apr 2024 13:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dbPk0RTL" Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 8F493135A4A for ; Tue, 23 Apr 2024 13:22:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713878540; cv=none; b=NdDDIRnikPZPXqpPsJ4Dh/P7PIVI+LFmS6AG9cO3LKI37FSqwVbg8Me9/mT9w/6RcGfEcYgS7bfLDEn8FzHWtCpwj18WHJI5oqnAl/+6AgbQ8pqv3S1b5NMg0XMZqpkECvGGYxci5rGAfP6ihPzg+VgwUSNbPRdw5mK07BFGvvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713878540; c=relaxed/simple; bh=Hv++gcciHk78PNTCIv/A2iJfPJVk4iYqFyoESE4aYIU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NNjGTNt/tVFf8+Nzz4aEa74VtN+RrwGSiklUZ+G6BTRYW78ksEONl5+8fHFCckH90/si6I6NcaWkamI5yjv+2dPiPPbeKErDIxd3D996gZtMh9xe8EaTkssv2uGa57baWnph2+4MJ8lg2dJUdC8Vy3SmYVPhFNcYFJG9Mop1dnU= 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=dbPk0RTL; arc=none smtp.client-ip=209.85.208.47 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 Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56e48d0a632so8401459a12.2 for ; Tue, 23 Apr 2024 06:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713878537; x=1714483337; 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=1n7JSfYWxQy0YOfnlGRtbUocgojCIv1pFKvACUA3fEs=; b=dbPk0RTLhSMQennpZ+/MswXVIM4JaPN9JZ/ZbACybcnJyBB/VA+19qmg6ckl97z9VG ofLPJIOJawEon/WREHrik5gKIxXKyqlP2ZqbrO5gxFhgmVMxwA2rlGz0R42vLIxwsek+ SilmKi0X7LwPTHx7w/RLiJ8JbStXJnPFIOgDUpaJJC9wYEulokrBJFujAQiyqh5rPwIz 3RSr/TPXiGBs5Jc2V8xsLTljtQUsSjRgIpwxOdAZDKxtqPdQv882oE4Ni8G3eslFjAHR U2GRFjoX3o++RfACiDsAV5UIddF511L28FLim7k373+ok2gLoPhXzWnh6JLG9d8W1QKE vQbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713878537; x=1714483337; 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=1n7JSfYWxQy0YOfnlGRtbUocgojCIv1pFKvACUA3fEs=; b=XbqfXxzPRhzx/4VOCHpINPiNLwGzU3Iqu7Qrc8HQgGKFv0mXxUl/bv9UBn1JmBZ/Qc i75LcWc7Wppg+VmbCtu1N6Nw/hboAiBTgnX6/q5ay39wqop8ITFJV1wvq/L6pUOeEjJn Bso+IjpcFWbF/efRv7vCgQPRn1h/C/b+i7XejrCDo1rSqEEkg0s6YrMosN6Pp1ioAcls EOj40swRkBI463LD8mx3mdVw6oZNbHv/s6DXqLM03i1mTOj0eq4XquMAL3tu+8UCb5gq yrq717czljpZZIZ/6ct9JSEpQz0HZIgGYRu+A991usZBAMOX9izPZDhT+eC/A/yTpR6t xbgg== X-Forwarded-Encrypted: i=1; AJvYcCUTVTsbqj50fmPyXR5hpYfA8cx/dGi6iaKOkOSPFw356pCU6ppTk6wbRJSBn3WGoTyyNmhM0rQbGaSzGz8g/MhTjkMiTBtSumHa2W8g X-Gm-Message-State: AOJu0Yyo5Ljoq+jBj5QVHXBHad/PPhs5VV6ukwJXSabUcqqZYDrmzS6n h2mG1+r/AC009Lu7Us1LaqcAzTLQTSVV+tEaaofDyiIl6MwGOzLbNwpPzu4PTUY= X-Received: by 2002:a17:907:1115:b0:a58:7ea5:c49b with SMTP id qu21-20020a170907111500b00a587ea5c49bmr1872927ejb.42.1713878536780; Tue, 23 Apr 2024 06:22:16 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id w23-20020a170907271700b00a556f2f18d6sm6980541ejk.57.2024.04.23.06.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:22:16 -0700 (PDT) Date: Tue, 23 Apr 2024 16:22:12 +0300 From: Dan Carpenter To: Bryan O'Donoghue Cc: Ricardo Ribalda , Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Stanimir Varbanov , Vikash Garodia , Bjorn Andersson , Konrad Dybcio , Benjamin Mugnier , Sylvain Petinot , Jacopo Mondi , Kieran Bingham , Laurent Pinchart , Niklas =?iso-8859-1?Q?S=F6derlund?= , Pavel Machek , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 11/35] media: s2255: Use refcount_t instead of atomic_t for num_channels Message-ID: References: <20240415-fix-cocci-v1-0-477afb23728b@chromium.org> <20240415-fix-cocci-v1-11-477afb23728b@chromium.org> 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: On Tue, Apr 23, 2024 at 01:43:49PM +0100, Bryan O'Donoghue wrote: > On 15/04/2024 20:34, Ricardo Ribalda wrote: > > Use an API that resembles more the actual use of num_channels. > > > > Found by cocci: > > drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363. > > drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558. > > Hmm, that commit log needs more detail. > > "Convert from atomic_t to refcount_t because refcount_t has memory ordering > guarantees which atomic does not, hence the WARNING for the free after the > atomic dec." > The memory ordering rules are the same. They're basically identical. The difference is that if you decrement a refcount_t past zero it will trigger an error and refuse but atomic_t will merrily keep decrementing forever. With refcount_t you can still have a use after free bug but afterward the double free will trigger a warning. There are time where people use atomic_t to get unique number and don't care about wrapping so that's fine. But if it's reference counting then use refcount_t. There wouldn't be a Fixes tag in this case, because hopefully it's just hardenning and not a bugfix. regards, dan carpenter