From patchwork Sat Sep 14 23:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdul Rahim X-Patchwork-Id: 829218 Received: from sonic313-20.consmr.mail.sg3.yahoo.com (sonic313-20.consmr.mail.sg3.yahoo.com [106.10.240.79]) (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 7C2571754B for ; Sat, 14 Sep 2024 23:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=106.10.240.79 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726356514; cv=none; b=kIYPMiiu5Px09d6OULDdMKuzWUFd/oMIUgLqvahytchlbtLtJInYOwPxRH2Qx8/+zyU0D7LHtxJZCsX8/k48Nkpiide5OVqpsJkc5rnL60O+dMt+CoxC91brsNiraT608Z8x8V6SSLBzeZHjX8FPjiHD+CUX4AKTpbN3EMeR8Es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726356514; c=relaxed/simple; bh=Emd4abe0oHfdm5VW4aDX6LLoJgAcXCzLVCOLXZmKLAI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:References; b=fICBW97lVJtRtO9DoeErV1Hxc6uHyYWqWnTXfoQ181v7SbewsPGqORep1hTObez5fBDCta5RsbPlqPNkRmtAanbr4BacfZ7LlqcjC2Il2Uh6B/0GV0J1jTUqoxWKmikg89h1IiWX2TSJl483LRTa2ohG2WXmlzh36+PrlRwckLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=myyahoo.com; spf=pass smtp.mailfrom=myyahoo.com; dkim=pass (2048-bit key) header.d=myyahoo.com header.i=@myyahoo.com header.b=Ji3HzvkA; arc=none smtp.client-ip=106.10.240.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=myyahoo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=myyahoo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=myyahoo.com header.i=@myyahoo.com header.b="Ji3HzvkA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myyahoo.com; s=s2048; t=1726356503; bh=TqTHPitrrLhLwGL6rNyIpEVqge6ePj8pP14s373Eogc=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=Ji3HzvkAZpemkE7BeapDgDiKleMFAyl7grlF85/l8Tmo+HFpCUgItrm7MkFiO1hdF6/T6w+x6LGdNRcya4qLEdv7hkxZPGoMZKO2QDH6YS0Atr5CPuXmhlB2qU569xv59aX33L/eakl0AS7Sz7882Z5L80NYF/CGoqAdlLlahR6oaI2dlKUg2a9OGMwW8hBd5uES7urDTWQL7G3NH3m+QdSlIG5TSiKAHnUL1N/ERCnpGBOI+JvZCk2Sv8EK4cABa5u37I0f82vji+VqsfHVKZVi64qxJLLAbhETqE09Lw2DaWm3KlI+JsZPE3EpkWT2PhvV6DzMYoafBy/ArQHV9A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1726356503; bh=47/RBK4F6FVYtdejh6kk5hKTUteXDjVCScPBdJDpDQO=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=QBZAYG3KJCr69wz6zvwqcgrsJ9V9Qg16tnSqBhIKr9EDT6rexDrOAj3v0gIDAak62TDYHf5YmgkZGpx8wkOB4VEMxjEtyDi3Bhu5HtADrDWKiyT5JMhf2nThQc5ItYoIvwlRdySCBUy2+xoNSknfk07Qt4D9R5B7sMnk4DBbJ2Pc4ob220omMFHKMmTsyjhrt6/1TS8mvtWov3XWzjH/t/jikpwvDP2xLpAW0oY+ZgKiwr3vi0XdDzVd6Mu6iX7NZSzJLCA87Mc8dbeAF6vkZ5cvVsI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qdEMmbe_J6BtSBqQnt9ALgFfrUikFMo6f IzHnn0qqN0kszmQJHCNWIumMpMJjURZD0UHYXxJfZPpdsMBK7_rHQgkz79paFyWnQ.sdhZ7I9k60 skXBsLj.rgJVp8p1VQRWNtJPz3svWJIvnk9j3ZlzGSLRRjcRu9p2pgpz.HYKlDA3IPOU6_indO9e VyMeaNVeN2VO9iSRG0Lv44lTdbe0Pmy_x92.Xb44PIGnax89jvSdTtHWA_8ku43V8 X-Sonic-MF: X-Sonic-ID: 8e4f8196-d385-481c-9291-452c447b5336 Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.sg3.yahoo.com with HTTP; Sat, 14 Sep 2024 23:28:23 +0000 Received: by hermes--production-sg3-fc85cddf6-6lk5x (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 02ee57d89096c2bea0084e4f53d4e48c; Sat, 14 Sep 2024 23:18:12 +0000 (UTC) From: Abdul Rahim To: gregkh@linuxfoundation.org, kees@kernel.org, m.grzeschik@pengutronix.de, quic_jjohnson@quicinc.com, gustavoars@kernel.org Cc: Abdul Rahim , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: f_midi: prefer strscpy() over strcpy() Date: Sun, 15 Sep 2024 04:47:49 +0530 Message-ID: <20240914231756.503521-1-abdul.rahim@myyahoo.com> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240914231756.503521-1-abdul.rahim.ref@myyahoo.com> The function strcpy() is depreciated and potentially unsafe. It performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy() [1]. this fixes checkpatch warning: WARNING: Prefer strscpy over strcpy Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] Signed-off-by: Abdul Rahim Reviewed-by: Kees Cook --- drivers/usb/gadget/function/f_midi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index 1067847cc079..837fcdfa3840 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c @@ -819,9 +819,9 @@ static int f_midi_register_card(struct f_midi *midi) goto fail; } - strcpy(card->driver, f_midi_longname); - strcpy(card->longname, f_midi_longname); - strcpy(card->shortname, f_midi_shortname); + strscpy(card->driver, f_midi_longname); + strscpy(card->longname, f_midi_longname); + strscpy(card->shortname, f_midi_shortname); /* Set up rawmidi */ snd_component_add(card, "MIDI"); @@ -833,7 +833,7 @@ static int f_midi_register_card(struct f_midi *midi) } midi->rmidi = rmidi; midi->in_last_port = 0; - strcpy(rmidi->name, card->shortname); + strscpy(rmidi->name, card->shortname); rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX;